Skip to content

getCompletionsAtPosition not triggering after emmet modifiers #5

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

Closed
pushqrdx opened this issue Mar 3, 2018 · 4 comments
Closed

getCompletionsAtPosition not triggering after emmet modifiers #5

pushqrdx opened this issue Mar 3, 2018 · 4 comments

Comments

@pushqrdx
Copy link

pushqrdx commented Mar 3, 2018

I am trying to implement emmet functionality inside typescript template literals however there's a strange behavior regarding getCompletionsAtPosition. with the following code from the demo completions aren't triggered if the position is after the number

            div*5
            div*5>li
    public getCompletionsAtPosition(context: TemplateContext, position: LineAndCharacter):
        CompletionInfo {
        const line = context.text.split(/\n/g)[position.line]
        return {
            isGlobalCompletion: false,
            isMemberCompletion: false,
            isNewIdentifierLocation: false,
            entries: [
                {
                    name: line,
                    kind: '',
                    kindModifiers: 'echo',
                    sortText: 'echo'
                }
            ]
        } as CompletionInfo
    }

To replicate, just use the demo EchoServer and test with emmet abbreviations above.

@pushqrdx
Copy link
Author

pushqrdx commented Mar 4, 2018

I have forked this repo and upon testing it seems that getCompletionsAtPosition get's called however it's return value doesn't populate vs' menu

Info 336  [4:0:40.281] request:
    {"seq":53,"type":"request","command":"completions","arguments":{"file":".../index.ts","line":72,"offset":21,"includeExternalModuleExports":true,"includeInsertTextCompletions":true}}
Info 337  [4:0:40.281] Starting updateGraphWorker: Project: c:/Users/Ahmed Tarek/Desktop/hivejs/tsconfig.json
Info 338  [4:0:40.281] Finishing updateGraphWorker: Project: c:/Users/Ahmed Tarek/Desktop/hivejs/tsconfig.json structureChanged: false Elapsed: 0ms
Info 339  [4:0:40.281] [typescript-inline-html-plugin] getCompletionsAtPosition Called!
Info 340  [4:0:40.281] [typescript-inline-html-plugin]             div*5>li
Perf 341  [4:0:40.281] 53::completions: elapsed time (in milliseconds) 0.2721
Info 342  [4:0:40.281] response:
    {"seq":0,"type":"response","command":"completions","request_seq":53,"success":true,"body":[{"name":"div*5>li","kind":"","kindModifiers":"echo","sortText":"echo"}]}

@mjbvz
Copy link
Contributor

mjbvz commented Mar 5, 2018

Take a look at how the styled-plugin supports emmet: https://github.com/Microsoft/typescript-styled-plugin/blob/master/src/styled-template-language-service.ts#L244 . You can also set "typescript.tsserver.trace": "verbose' in vscode and look in the typescript section of the output panel to make sure your completion is being returned

Also note that emmet requires that completions be recalculated when a new character is typed, which is not a normal TS behavior (see the note on https://github.com/Microsoft/typescript-styled-plugin#emmet-in-completion-list). My proposal is to make TypeScript allow plugins to pass some metadata through to VS Code so that we can support this. This is already tracked by microsoft/TypeScript#21999 but I decided not to add emmet to the lit-html plugin yet because the current user experience is so poor

@pushqrdx
Copy link
Author

pushqrdx commented Mar 5, 2018

@mjbvz as i stated, the completion returns yet it doesn't populate the menu when the cursor is

div5>HEREli or div5>liHERE

to further confirm the issue i created an extension language and further explained it here, if you can take a look i would be very grateful.

@mjbvz
Copy link
Contributor

mjbvz commented Mar 7, 2018

Closing as duplicate of microsoft/vscode#45028

@mjbvz mjbvz closed this as completed Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants