Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Pressing . automatically chooses the selected completion suggestion #160

Closed
gwhobbs opened this issue Jan 1, 2021 · 18 comments
Closed

Pressing . automatically chooses the selected completion suggestion #160

gwhobbs opened this issue Jan 1, 2021 · 18 comments
Labels
dependency Something is a dependencies fault nova-core Something is (probably) Nova's fault

Comments

@gwhobbs
Copy link

gwhobbs commented Jan 1, 2021

A clear and concise description of what the bug is.

Pressing . automatically chooses the selected completion suggestion. This frequently results in undesirable behavior—for example, console.log is often transformed into Console.log. When not using this extension, Nova keeps whatever was typed unless e.g. tab was pressed.

To reproduce

Steps to reproduce the behavior:

  1. Start typing something that produces a completion suggestion
  2. Press .

Expected behavior

The typed text is unaltered.

Screenshots

log

Environment

  • Nova version: 3.1 (211256)
  • Extension version: 2.1.0
  • TypeScript version: 4.1.3 (problem seems to affect other versions as well)
  • Sidebar information: Status Running Typescript Version Version...
  • macOS version: 10.15.7 (19H114)
  • NodeJS information:
    • node version: v14.15.1
    • npm version: 6.14.9
    • installation method: n

Extension console output

No Typescript-related output generated when problem occurs.

Additional context

I have experienced this issue since Nova was in beta.

@gwhobbs gwhobbs added the bug Something isn't working label Jan 1, 2021
@apexskier
Copy link
Owner

This is actually a "feature" of the language server the extension uses and language server protocol.

https://github.com/theia-ide/typescript-language-server/blob/3a8ea0f04bde047e2f60b9f68ef7816e3a41aa10/server/src/lsp-server.ts#L147

I also find this a bit annoying - I'll investigate if there's a way to override the default.

@apexskier apexskier added dependency Something is a dependencies fault and removed bug Something isn't working labels Jan 19, 2021
@zaceno
Copy link

zaceno commented Feb 2, 2021

I will also add that pressing comma (,) inside object literals has the same annoying behavior. If there's a way to override the . forcing autocompletion I hope it would be possible to override this comma-behavior as well.

An example: I type: let foo = {bar: 2 ...press "," ... and the result is let a = {b: Path2D, 😓

It seems over-eager to chose completions that aren't even a very close match, like matching 2 to Path2D, or 4 to Float64Array. Usually when I type a number all I mean to type is a number.

@logancollins
Copy link

We've heard a couple of reports about this from other users in Nova as well. @apexskier, if there's anything we need or could do from our side to make things better for the LSP extension, please let us know!

@exPHAT
Copy link

exPHAT commented Feb 15, 2021

Huge +1 on this. Super annoying when the autocomplete re-prompts even after editing my mistake (then I proceed to have the autocomplete win 2-3 more times before I can type what I want).

Any update on overriding the default?

@apexskier
Copy link
Owner

apexskier commented Feb 19, 2021

I wasn't able to find a way to override through typescript-language-server or the language server protocol itself, so I don't have any ideas of how Nova could address it cleanly.

It looks like the original reason for this was to match VSCode behavior which still exists. I played around a bit and it appears that VSCode does the same thing as nova with respect to replacing with the chosen suggestion. The actual issue might be that the ordering of suggestions is a lot worse in Nova/this extension.

The extension doesn't have any control over autocomplete, so there could be an issue in Nova's LSP client side or typescript-language-server's side.

VSCode

code.mov

Nova

nova.mov

@apexskier
Copy link
Owner

After a quick scan, I don't see any sorting logic in vscode or the language server.

@apexskier
Copy link
Owner

The actual issue might be that the ordering of suggestions is a lot worse in Nova/this extension.

I'm doing some more digging, and it also seems like the filtering logic is different from VSCode.

@apexskier
Copy link
Owner

@logancollins Does Nova do a full completionItem/resolve when applying autocompletion? I'm not seeing the server method called when I choose an item. This is important for items with associated commands/text edits for tsserver, it looks like, so it might be causing "broken" autocompletions.

@zaceno
Copy link

zaceno commented Feb 21, 2021

@apexskier just want to say thanks for digging in to this and keep up the good work! Happy hunting!

@logancollins
Copy link

@apexskier Correct, Nova does not currently support the resolve request in the Language Server Protocol. We hope to look into adding support for this at some point. I can see if we can try and schedule this for the next feature milestone. So far, we haven't encountered (or heard encounter of) any LSPs actually using it, but clearly it would be required for full tsserver support.

I would imagine the item ordering algorithm used by Nova is not exactly the same as VSCode. Nova uses an n-gram sorting algorithm that allows for fuzzy-matching. I am aware that the LSP completion items can optionally provide a string override for use when sorting, but Nova currently ignores it. It may be worth it for us to revisit this and see if there's a better way we can ensure that items returned from a language server can maintain their ordering relative to each other, while still applying fuzzy matching and allowing the rest of Nova's completion providers to inter-sort properly.

I am not offhand sure what they might be doing, as I generally tend to avoid reading the VSCode source to avoid any reverse engineering legal issues from our perspective. (Call me paranoid, I guess. 😄)

@apexskier
Copy link
Owner

From what I saw in VSCode source, they're using the sortText concept from the language server protocol (not directly, but the same concept). Support for that would significantly help here I think.

@apexskier apexskier added the nova-core Something is (probably) Nova's fault label Feb 23, 2021
@abelespana
Copy link

The latest Nova update (7.0, released yesterday) fixes the problem for me. Great job!

@apexskier
Copy link
Owner

@abelespana interesting. I still see . and , act as a trigger characters. The suggestions might have improved (Console is no longer suggested) but I think that was a prior release.

@Corack117
Copy link

I have the same problem, when I use. " or "," I do the self-tasting, I had to deactivate the section of Completions so that the problem does not happen, unfortunately, remove several increasing when programming

Nova version: 7.4
Typescript extension: 2.4.0

@michaelflores-italic
Copy link

michaelflores-italic commented Nov 16, 2021

I will say I've also found this to be quite problematic, and just generally felt the auto-complete in Nova was wonky to the point of generating multiple bug reports but it's hard to tell at times whether it's Nova or this extension the root cause is in. Curious at this point if there is anything planned or further work that could be done on improving this particular issue (happy to try and help), or is it still on Nova to fix it? I still have this behavior in Nova 8.1 and when I emailed them about it, they referred to the extension.

Nova version: 8.1
Typescript extension: 2.4.0

@logancollins
Copy link

You will all likely be very happy to hear that we've added an explicit preference to the upcoming Nova 9 to disable completion trigger characters defined by language servers. This should prevent characters like . from accepting the selected completion item. I regret that it's taken us so long to finally do this.

@codebykenny
Copy link

@logancollins this is great news, is there a way to get access to the Nova 9 version as a tester? Unfortunately in my projects, this particular issue makes Nova 8 unusable. The "." key randomly inserts characters as I type

Kenny-.2022-02-03.at.09.07.29.mp4

@apexskier
Copy link
Owner

Nova 9 has been released

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependency Something is a dependencies fault nova-core Something is (probably) Nova's fault
Projects
None yet
Development

No branches or pull requests

9 participants