-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Quick-fixes that insert text with completion/choices show backslashes in front of closing curly braces #54403
Comments
Also, maybe this should be a separate issue but I'll ask here anyway just to be sure. If you do: abstract class C {
void fn(({int b, int a}) r);
}
class D extends C {
} Using the quick fix reorders the named values to be in alphabetical order: abstract class C {
void fn(({int b, int a}) r);
}
class D extends C {
@override
void fn(({int a, int b}) r) {
// TODO: implement fn
}
} That could make some users a little confused when searching by text for the same record that was originally written (which happened to me). Is this intended and if so, why? |
Thanks for reporting the problem with the slash! As for the re-ordering, that's an unfortunate consequence of the internal implementation and/or specification. Two records types are considered to be the same if the number and types of the positional fields match, and if the names and types of the named fields match. In other words, the order of the named fields isn't considered when comparing record types. In order to implement this efficiently, the |
I see, thanks for clarifying! Just a new update. tested with a |
non_abstract_class_inherits_abstract_member
quick fix bug with Iterable<Record>
non_abstract_class_inherits_abstract_member
quick fix bug with <Record>
non_abstract_class_inherits_abstract_member
quick fix bug with <Record>
non_abstract_class_inherits_abstract_member
quick fix bug with last named value in Record
inside <>
pair
I'm not sure where the problem might be. I was able to reproduce the issue in VS Code using a build from HEAD, with
I thought I had an idea of where the bug might be, so I wrote a test of @DanTup It's possible that my test of LSP isn't right, but it looks like the right edit is getting returned. Is there any chance the bug is on the DartCode or VS Code side? |
Tested on IntelliJ CE, no issues. Seems to me that the problem is only with VSCode |
Here's what the edit looks like in the JSON from the server: {
"insertTextFormat": 2,
"newText": "$0\n @override\n void m(${1|Iterable<({int a\\, int b\\})>,Object|} ${2:r}) {\n // TODO: implement m\n }\n",
"range": {
"end": {
"character": 19,
"line": 4
},
"start": {
"character": 19,
"line": 4
}
}
} This looks correct to me - there are two backslashes - one to escape the other backslash in the string, meaning the actual content looks like:
The remaining backslashes are to escape the comma (so it's not a separator between the two choices) and the closing bracket (so it doesn't end the choice block) - this seems to match what's documented here. So assuming I'm interpreting the escaping rules correctly, I think it's either a bug in Dart-Code (if we're doing any massaging of this value), or VS Code. Will take a look. |
IMO this is a VS Code bug, because we're escaping a character that the docs say can be escaped. However, it could be argued that the escaping is unnecessary in a choice, because they're surrounded by sdk/pkg/analysis_server/lib/src/lsp/snippets.dart Lines 152 to 153 in 2261250
|
Apparently this isn't a bug and we should not escape any characters for the specific cases that don't require it (eg. in choices, we cannot escape I've opened some PRs to VS Code + LSP docs to try and make this concrete before I start changing things: microsoft/language-server-protocol#1868 |
non_abstract_class_inherits_abstract_member
quick fix bug with last named value in Record
inside <>
pair
The VS Code docs + LSP changes landed. I've opened a server fix at https://dart-review.googlesource.com/c/sdk/+/345661 |
Describe the issue
When using the quick-fix for missing override, with an
Iterable<Record>
(tested withSet
andList
as well), the last item inside the record always ends with\
at the end.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected the quick fix to not add
\
at the end.Screenshots
20231215_104425.mp4
The text was updated successfully, but these errors were encountered: