Skip to content

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

Closed

Description

@HaoboGu
  • 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

Activity

  1. vscodebot commented on Dec 25, 2020

    @vscodebot

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

  2. HaoboGu commented on Dec 30, 2020

    @HaoboGu
    ContributorAuthor

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

  3. HaoboGu commented on Dec 30, 2020

    @HaoboGu
    ContributorAuthor

    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

  4. added
    suggest
    on Jan 4, 2021
  5. jrieken commented on Jan 4, 2021

    @jrieken
    Contributor

    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 {

  6. added
    help wanted
    on Jan 4, 2021
  7. HaoboGu commented on Jan 4, 2021

    @HaoboGu
    ContributorAuthor

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

    Johannes Rieken (@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.

  8. jrieken commented on Jan 4, 2021

    @jrieken
    Contributor

    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.

  9. HaoboGu commented on Jan 4, 2021

    @HaoboGu
    ContributorAuthor

    So the adiv case is by design, right?

  10. jrieken commented on Jan 4, 2021

    @jrieken
    Contributor

    yes, see here #53715

  11. HaoboGu commented on Jan 4, 2021

    @HaoboGu
    ContributorAuthor

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

  12. added 2 commits that reference this issue on Jan 5, 2021
    3f435ff
    bc22334
  13. 11 remaining items

  14. HaoboGu commented on Jan 27, 2021

    @HaoboGu
    ContributorAuthor

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

  15. removed
    verification-found
    verification-needed
    on Jan 27, 2021
  16. jrieken commented on Jan 27, 2021

    @jrieken
    Contributor

    Not critical for this release, moving to February

  17. alexdima commented on Jan 27, 2021

    @alexdima
    Member

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

  18. connor4312 commented on Jan 27, 2021

    @connor4312
    Member

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

  19. added
    feature-request
    verified
    on Jan 27, 2021
  20. added
    verification-needed
    on Jan 27, 2021
  21. locked and limited conversation to collaborators on Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requesthelp wantedsuggestverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions