Skip to content

Autocomplete for symbols from package:charcode ends up with duplicated dollar ($) characters #3943

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
jamesderlin opened this issue Apr 26, 2022 · 3 comments
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Milestone

Comments

@jamesderlin
Copy link

Describe the bug
When I attempt to autocomplete the generated symbols from package:charcode that start with a $ character, the autocompleted symbol ends up with $$.

To Reproduce

  1. Add import 'package:charcode/charcode.dart'; to some .dart file.
  2. Start typing $ba. The autocomplete list appears, listing $backquote, $backslash, ...
  3. Press Tab.

$ba gets autocompleted to $$backquote.

Expected behavior
$ba should have been autocompleted to $backquote.

Other notes
Strangely, if I define my own variable (e.g. var $foo = 'bar';), then that seems to autocomplete fine. I'm not sure why the symbols from package:charcode are autocompleting differently.

Versions

  • Operating System and version: Ubuntu 20.04.4 LTS (x64)
  • VS Code version: 1.66.2
  • Dart extension version: 3.38.2
  • Dart/Flutter SDK version: Dart 2.16.2
@DanTup
Copy link
Member

DanTup commented Apr 27, 2022

Strangely, if I define my own variable (e.g. var $foo = 'bar';), then that seems to autocomplete fine. I'm not sure why the symbols from package:charcode are autocompleting differently.

It looks like for "external" items, we don't provide the textEdit up-front (computing it lazily instead):

Screenshot 2022-04-27 at 10 33 19

This is not valid, so I'm not sure how we ended up doing this. What's happening here is that VS Code is guessing which range to replace (since the lazy-computed one from the server is too late), and it doesn't know that $ is a valid part of identifier.

@DanTup DanTup added in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server labels Apr 27, 2022
@DanTup DanTup added this to the v3.40.0 milestone Apr 27, 2022
@DanTup
Copy link
Member

DanTup commented Apr 27, 2022

Fixing this by adding the edits to every completion item bloats the payload quite significantly, so I'm going to bump fixing this until next month, when LSP 3.17 should have been released and we can use CompletionList.itemDefaults to set the range.

@DanTup DanTup modified the milestones: v3.40.0, v3.42.0 Apr 27, 2022
@DanTup DanTup modified the milestones: v3.42.0, v3.44.0 May 25, 2022
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Jun 14, 2022
Not providing textEdit means that the client will use insertText and compute its own range for what needs to be replaced. This may be incorrect if the name includes symbols that VS Code doesn't realise are part of the identifier.

To fix this, we should _always_ supply the range. This will result in a slightly larger payload, although an upcoming change to use itemDefaults will remove that for supporting clients.

Fixes Dart-Code/Dart-Code#3943.

Change-Id: Ifd3f38ef96fecc6c745e00f511eb0bdbbd0d4a82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248143
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
@DanTup
Copy link
Member

DanTup commented Jun 20, 2022

Fixed by dart-lang/sdk@40e25eb.

@DanTup DanTup closed this as completed Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in editor Relates to code editing or language features in lsp/analysis server Something to be fixed in the Dart analysis server is bug
Projects
None yet
Development

No branches or pull requests

2 participants