Skip to content

x/tools/gopls: fix folding range for function calls #75229

@ShoshinNikita

Description

@ShoshinNikita

gopls version: gopls@974c859 (master)

CL https://go.dev/cl/694295 changed the folding logic and reintroduced behavior reported and fixed in #70467:

Lack of the closing parenthesis makes code editing more difficult. For example, users have to unfold fmt.Println to add more code. This behavior is particularly frustrating when working with calls like t.Run.

Also, there's a conflict between gopls' and VSCode's logic that makes this issue extremely annoying.

1.mp4
Code snippet from the video
func _() {
	slice := []int{1, 2, 3}
	sort.Slice(slice, func(i, j int) bool {
		a, b := slice[i], slice[j]
		return a < b
	})

	sort.Slice(
		slice,
		func(i, j int) bool {
			return slice[i] < slice[j]
		},
	)

	fmt.Println(
		1, 2, 3,
		4,
	)
}

func TestA(t *testing.T) {
	t.Run("add", func(t *testing.T) {
		_ = 1 + 1
	})

	t.Run("sub", func(t *testing.T) {
		_ = 1 - 1
	})
}

func TestB(t *testing.T) {
	_ = 123
}

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions