Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SimplifyfilterText computation + fixes#1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gabritto wants to merge10 commits intomain
base:main
Choose a base branch
Loading
fromgabritto/vscodetests

Conversation

gabritto
Copy link
Member

@gabrittogabritto commentedJul 17, 2025
edited
Loading

This PR simplifies the computation of a completion item'sfilterText which was ported from the VSCode TS extension. There were originally two pieces of code wherefilterText was computed, and I think one of those was mostly unnecessary, so I removed it and simplified the rest of the code.

The code I removed used to setfilterText for all dot completions, which wasn't needed, so the Corsa tests have been updated to reflect that, and a bunch of tests ported from Strada now pass as well because we no longer setfilterText in most cases.

I also added tests for all the cases where I thinkfilterText is necessary, since this piece of code is new and so not covered by Strada tests.

This PR also fixes two porting bugs, one in the parser and one bug in the scanner, and some minor completion bugs.

iffilterText=="" {
filterText=getFilterText(file,position,insertText,name,isMemberCompletion,isSnippet,wordStart)
}
ifisMemberCompletion&&!isSnippet {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This code here was removed because it mostly overlapped withgetFilterText above.

m(){
this.;
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This results from fixing the scanner bug.

@gabrittogabritto marked this pull request as ready for reviewJuly 17, 2025 22:12
Copy link
Member

@DanielRosenwasserDanielRosenwasser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Seems okay, just wanted to clarify a few things before approving.

@@ -2127,41 +2143,45 @@ func getFilterText(
// In which case we want to insert a bracket accessor but should use `.abc` as the filter text instead of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is sort of an aside, but I don't understand why conceptually the "access operator" (the. or?.) is part of the filter text at all.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The client will rank the completion items by comparing the filter text with some suffix of the existing test at the completions position. The suffix is usually the word touching the position, but may be a custom range when the item specifies a text edit.
Given that, we want to use the filter text to avoid the client overly de-ranking or omitting completions that have to modify some of the text that the user already typed.
For instance, if we have this:

declareconstobj:{"ab c":string};obj.a|

The completion item forab c will need to insert["ab c"], and it will specify a range in the text edit covering.a, but we want it to be ranked by the client the same as a regular property should, so the client should compare.a (text at current position that the item will replace) with.ab c, instead of["ab c"], because["ab c"] doesn't really match.a.

The access operator is there because in the situations where we use it in the filter text, it is part of the text that will be replaced if you accept the completion item, so it is part of what will be compared with the filter text.
That said, it's possible there are some cases where we currently set the filter text that could be optimized away.

}
s.token=ast.KindPrivateIdentifier

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Seems fine, but why did we need this? Or, why is Strada able to get away without this?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The new code does what Strada does. The code before this PR seems like a porting bug.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@DanielRosenwasserDanielRosenwasserDanielRosenwasser left review comments

@sandersnsandersnAwaiting requested review from sandersn

@andrewbranchandrewbranchAwaiting requested review from andrewbranch

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@gabritto@DanielRosenwasser

[8]ページ先頭

©2009-2025 Movatter.jp