Dart-code: Stop "tabstops" in completion snippets from highlighting all text typed at that location

Created on 23 Aug 2018  路  14Comments  路  Source: Dart-Code/Dart-Code

Select inserted text after Code Completion.
It won't appear Code Completion when inputting text in inserted text.

wechatimg3

in editor is enhancement

Most helpful comment

@brianegan I hadn't seen that - thanks for the ping! I've opened https://github.com/Dart-Code/Dart-Code/issues/2248 about this - my comment above suggests I couldn't repro this any more, but that video suggests it's occuring. I'll take a look and if there's no obvious fix I'll revert the default of that setting in the meantime.

All 14 comments

I'm not sure exactly what's being asked for here, could you give more details?

This is a gif to show issue:

ca3dae8e-b331-4c07-8b41-964877854c81

I'm afraid I'm still not sure what's being asked for (or is wrong?). Are you saying something is wrong (eg. it's selecting text it shouldn't), or asking for a change (eg. to select some text?).

it's selecting text it shouldn't

Oh, I see what you mean now. This isn't a "selection" as when you type, it would replace that text if it was. I think this is the "placeholder" which lets you tab between values. I don't think it should ever start with a placeholder of 0 characters though, I'll do some digging.

Is it possible you could run the Dart: Capture Logs command, select the Analysis Server category and reproduce this, and then attach the log?

Yes, it's my pleasure, this is the log:

Dart-Code-Log-2018-07-06 17-08.txt

Thanks - I can reproduce this, but it seems like it's designed behaviour of VS Code :(

When we provide a completion when insertArgumentPlaceholders is enabled (the default), we give VS Code a completion like:

Container($1)$2

The $1's are tab stops. If you press <tab> after completing, you'll see the selection jumps between them. VS Code highlights the selected tab stop - this seems unwanted to me.

I've opened https://github.com/Microsoft/vscode/issues/57251~~ (edit: this was a dupe of https://github.com/Microsoft/vscode/issues/43270) to see if they agree it could be handled better.

In the last 30 min, another two people have reported this. I think we need to change something for vNext even if it's not a perfect fix.

I think this is still occurring on 2.20 Beta 2, albeit in fewer scenarios.
GIF reproduction

@Skylled Indeed, it'll still happen for any completions that have arg placeholders (eg. required params), because that's the only way we can allow you to tab between them. If you disable the dart.insertArgumentPlaceholders setting it'll go away, but you won't get the placeholder values inserted. I don't believe there's any way to have the placeholders but not have this annoying behaviour.

I intend to completely remove insertArgumentPlaceholders when we can reliably trigger signature help automatically (this needs SDK work I haven't gotten round to), though enabling commit characters also disables it (though the logic for why somewhat escapes me).

I'd encourage you to try dart.insertArgumentPlaceholders: false for a while and see how it feels and let me know. I'll be sure to tweak the release notes to make it clearer that this case still remains and the reasons before releasing.

A heads up - in an upcoming release I'm reverting part of the fix for this issue as part of trying to make completion more consistent (https://github.com/Dart-Code/Dart-Code/issues/1940) and work better for @required params (https://github.com/Dart-Code/Dart-Code/issues/2123).

There are two issues described above:

  1. A block of code is "highlighted" if it was being typed into a tabstop
  2. Completion does not work when in this "snippet mode"

The fix was to force the tabstop to be the last one, which meant you'd exit snippet-mode immediately. This works fine for invocations with only a single argument placeholder, but if there are multiple you still see stay in snippet-mode. It would also prevent you tabbing out to after the ) and having to use cursor keys (which is what https://github.com/Dart-Code/Dart-Code/issues/1940 describes).

The second issue appears to have been fixed by VS Code - code completion (at least in my testing) works fine inside this snippet mode. Therefore I think reverting the fix to resolve https://github.com/Dart-Code/Dart-Code/issues/1940 is the best option. You'll still see the highlighted snippets but I think that's really just cosmetic (besides the change in handling of the tab key).

For the next release, this new behaviour will be behind a preview flag (dart.previewNewCompletionPlaceholders and called out in the release notes), but it's likely (depending on feedback) to become default in the following release.

@DanTup Hope all is Well :)

Sorry to dig up an old issue, but someone reported some more issues with this on Reddit, not sure if ya saw and wanted to point it out: https://www.reddit.com/r/FlutterDev/comments/ez5yog/ive_been_having_trouble_with_vscode_recently_can/

@brianegan I hadn't seen that - thanks for the ping! I've opened https://github.com/Dart-Code/Dart-Code/issues/2248 about this - my comment above suggests I couldn't repro this any more, but that video suggests it's occuring. I'll take a look and if there's no obvious fix I'll revert the default of that setting in the meantime.

I've pushed out v3.8.1 which should fix this issue (while still supporting the new placeholders) - for anyone having issues that may have disabled this, please update to v3.8.1 and re-enable and let me know if you still have issues. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rgb1380 picture rgb1380  路  3Comments

DanTup picture DanTup  路  3Comments

jascodes picture jascodes  路  4Comments

rajeshjeshar picture rajeshjeshar  路  4Comments

mayorbyrne picture mayorbyrne  路  5Comments