-
Notifications
You must be signed in to change notification settings - Fork 133
Port regex-based block formatting from vscode-python #217
Conversation
|
||
[TestMethod, Priority(0)] | ||
public async Task FirstLine() { | ||
using (var reader = new StringReader("")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need using for StringReader
when it is used explicitly. It doesn't hold any resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can certainly remove it, but I'm a little bit wary of not disposing of it just because we know it doesn't do anything given that a future .NET release could easily implement it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are really concerned about resources, then use string.Empty
and not ""
;-)
Actually, I believe it used to be disposable and held resources back in a day, but not anymore and no one disposes of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's disposable because it's a subclass of TextReader
, which is IDisposable
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix that string.Empty
thing though. Muscle memory from other languages which don't allocate an empty string...
* port block formatting on colon from vscode-python * port tests * basic check in LanguageServerTests * split apart LanguageServer tests for OnTypeFormatting * string.Empty instead of empty literal
Updates #165.
This is a 1:1 port of the
:
triggered block formatter that's running in the extension, including its tests. See here for the current implementation:This may not be the most efficient or most correct way to do this sort of formatting, but not having any block formatting in PLS means that we can't also ship the line formatting code. This will at least behave the same way and let us ship the new line formatter without regressing the editor in terms of features. This can be replaced later with something that uses the tokenizer/parser to act much more generally.