-
Notifications
You must be signed in to change notification settings - Fork 8
fix: when autocompleting with insertText, use that rather than name #562
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,23 @@ function mapCompletions( | |
return completions.entries | ||
.filter((entry) => filter({ trigger, kind: entry.kind, name: entry.name })) | ||
.map((entry) => { | ||
/* | ||
With the includeCompletionsWithInsertText option set, auto-completions | ||
might have an insertText property for cases like where a property has | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other cases are there and should we add tests for those as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't think of any. Once I do I'll add regression tests ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably dashes, spaces, quotes.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, will be interesting to see some corner cases involving quotes - e.g. a collection called |
||
to be escaped. | ||
|
||
An obvious example is autocompleting a collection name that has a dot in | ||
it. Let's say you have the text db.fo and the collection name is foo.bar. | ||
name would be 'foo.bar' and insertText would be '["foo.bar"]'. | ||
|
||
In that case we also want to strip the dot from the prefix. | ||
*/ | ||
const result = entry.insertText | ||
? prefix.slice(0, -1) + entry.insertText | ||
: prefix + entry.name; | ||
|
||
return { | ||
result: prefix + entry.name, | ||
result, | ||
name: entry.name, | ||
kind: entry.kind, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... why are we getting these completions? Shouldn't they be filtered out since they don't start with
fo
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger is a blank string in this case: