Skip to content
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

Wrong highlight if there are duplicate strings in completion item #113404

Closed
HaoboGu opened this issue Dec 25, 2020 · 15 comments · Fixed by #113837
Closed

Wrong highlight if there are duplicate strings in completion item #113404

HaoboGu opened this issue Dec 25, 2020 · 15 comments · Fixed by #113837
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@HaoboGu
Copy link
Contributor

HaoboGu commented Dec 25, 2020

  • VSCode Version: 1.52.1
  • OS Version: MacOS Big Sur 11.1

If a suggestion contains two "div", the second "div" is wrongly highlighted after "di" is entered

div

Does this issue occur when all extensions are disabled?: No, with my customed completion extension

@vscodebot
Copy link

vscodebot bot commented Dec 25, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@HaoboGu
Copy link
Contributor Author

HaoboGu commented Dec 30, 2020

@jrieken I'd like to open a PR to fix it, would you please give me some hints about where can I start?

@HaoboGu
Copy link
Contributor Author

HaoboGu commented Dec 30, 2020

Steps to reproduce it:

  1. Create an extension, use the following extension.ts
import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
	const provider1 = vscode.languages.registerCompletionItemProvider('plaintext', {
		provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
			const simpleCompletion = new vscode.CompletionItem('⭐div classname=""></div>');
			return [simpleCompletion];
		}
	}, ' ', '.', '<');
	context.subscriptions.push(provider1);
}

export function deactivate() {}
  1. Set activateEvent in package.json:
"activationEvents": [
		"*"
	],
  1. open a txt and enter character "d"
    image

only the later "d" is highlighted

@jrieken jrieken added the suggest IntelliSense, Auto Complete label Jan 4, 2021
@jrieken
Copy link
Member

jrieken commented Jan 4, 2021

Understood. Our fuzzy score function treats certain characters as separators, like _ and .. However, emojis and such aren't on that list. The code is here:

function isSeparatorAtPos(value: string, index: number): boolean {

@jrieken jrieken added the help wanted Issues identified as good community contribution opportunities label Jan 4, 2021
@HaoboGu
Copy link
Contributor Author

HaoboGu commented Jan 4, 2021

Understood. Our fuzzy score function treats certain characters as separators, like _ and .. However, emojis and such aren't on that list.

@jrieken Thanks for the hint! Here is another case, the later match of di is highlighted even though the first character is not emoji nor symbol.
image

It seems that just adding emoji or symbols to isSeparatorAtPos couldn't solve the entire problem.

@jrieken
Copy link
Member

jrieken commented Jan 4, 2021

That is a different case. Having adiv and di isn't match for us because the first match (d in ad) is considered weak. A strong match is one after a separator or a the word start and matches much start with a strong match.

@HaoboGu
Copy link
Contributor Author

HaoboGu commented Jan 4, 2021

So the adiv case is by design, right?

@jrieken
Copy link
Member

jrieken commented Jan 4, 2021

yes, see here #53715

@HaoboGu
Copy link
Contributor Author

HaoboGu commented Jan 4, 2021

Thanks, I'll open a PR to fix the emoji case ;D

HaoboGu added a commit to HaoboGu/vscode that referenced this issue Jan 5, 2021
HaoboGu added a commit to HaoboGu/vscode that referenced this issue Jan 6, 2021
jrieken added a commit that referenced this issue Jan 11, 2021
Add emojis and several more symbols as word separators, fix #113404
@jrieken jrieken added this to the January 2021 milestone Jan 11, 2021
@jrieken jrieken added verification-needed Verification of issue is requested and removed unreleased Patch has not yet been released in VS Code Insiders labels Jan 11, 2021
@connor4312 connor4312 added the verified Verification succeeded label Jan 27, 2021
@connor4312
Copy link
Member

This doesn't seem to be working for me in the latest Insiders. I don't see the highlight after the emoji, and the match doesn't come up if I start typing div in a suggestion that contains only ⭐div

@connor4312 connor4312 reopened this Jan 27, 2021
@connor4312 connor4312 added verification-found Issue verification failed and removed verified Verification succeeded labels Jan 27, 2021
@HaoboGu
Copy link
Contributor Author

HaoboGu commented Jan 27, 2021

This doesn't seem to be working for me in the latest Insiders. I don't see the highlight after the emoji, and the match doesn't come up if I start typing div in a suggestion that contains only ⭐div

Can you try other emoji like ✨ ?
In my insiders it works:
image

It seems that '⭐' is not included by

export function isEmojiImprecise(x: number): boolean {
return (
(x >= 0x1F1E6 && x <= 0x1F1FF) || (x >= 9728 && x <= 10175) || (x >= 127744 && x <= 128591)
|| (x >= 128640 && x <= 128764) || (x >= 128992 && x <= 129003) || (x >= 129280 && x <= 129535)
|| (x >= 129648 && x <= 129651) || (x >= 129656 && x <= 129666) || (x >= 129680 && x <= 129685)
);
}

@HaoboGu
Copy link
Contributor Author

HaoboGu commented Jan 27, 2021

@alexdima do you have any suggestions on it? I would like to fix isEmojiImprecise if possible

@jrieken jrieken modified the milestones: January 2021, February 2021 Jan 27, 2021
@jrieken jrieken removed the verification-found Issue verification failed label Jan 27, 2021
@jrieken jrieken removed the verification-needed Verification of issue is requested label Jan 27, 2021
@jrieken
Copy link
Member

jrieken commented Jan 27, 2021

Not critical for this release, moving to February

@alexdima
Copy link
Member

I've created #115221 to track the isEmojiImprecise problem.

@connor4312
Copy link
Member

I can verify it works with ✨, so I'll close this and mark as verified pending Alex's new issue

@connor4312 connor4312 added feature-request Request for new features or functionality verified Verification succeeded labels Jan 27, 2021
@connor4312 connor4312 added the verification-needed Verification of issue is requested label Jan 27, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@jrieken @connor4312 @alexdima @HaoboGu and others