Skip to content

Content mapper duplicated inlay hintsΒ #64050

Description

πŸ”Ž Search Terms

inlay hints
content-mapper

πŸ•— Version & Regression Information

I was unable to test this on prior versions because this is newly added

⏯ Playground Link

No response

πŸ’» Code

πŸ™ Actual behavior

When a content mapper splits a statement into multiple spans, the inlay hints result is duplicated. In the inlay hints request, the request range is mapped into multiple ranges and calculated separately. Because the statement is in multiple spans, the hint for that statement is returned multiple times.

Four slash test failed case:

package fourslash_test

import (
	"testing"

	"github.com/microsoft/TypeScript/tsc/internal/ls/lsutil"
	"github.com/microsoft/TypeScript/tsc/internal/testutil"
	"github.com/microsoft/TypeScript/tsc/internal/testutil/contentmappertest"
)

func TestContentMapperInlayHints(t *testing.T) {
	t.Parallel()
	defer testutil.RecoverAndFail(t, "Panic on fourslash test")
	f, done := newContentMapperFourslash(t, `// @Filename: /app.lisp
(+ 1 2 "oops")

// @Filename: /main.ts
declare function add(a: number, b: number, c: string): number;
`, contentmappertest.LispMapper, ".lisp")
	defer done()

	f.GoToFile(t, "/app.lisp")
	f.VerifyBaselineInlayHints(t, nil /*span*/, &lsutil.UserPreferences{InlayHints: lsutil.InlayHintsPreferences{IncludeInlayParameterNameHints: lsutil.IncludeInlayParameterNameHintsAll}})
}

πŸ™‚ Expected behavior

Probably need to deduplicate when multiple spans map to the inlay hint request range.

Additional information about the issue

No response

Metadata

Metadata

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions