vscode-haxe
vscode-haxe copied to clipboard
Indent breaks with completion using trimTrailingWhitespace
I just pull the latest version of vscode-haxe and it appear that autocompletion is breaking the current indentation when there is no dot in the line to autocomplete.
For example :
public function render(g: Graphics): Void {
image
g.drawImage(_texture, rect.origin.x, rect.origin.y);
}
Become :
public function render(g: Graphics): Void {
image
g.drawImage(_texture, rect.origin.x, rect.origin.y);
}
To reproduce this bug, you can simply try to press enter
at the end of a line. Wait 1sec, and their you should see that your cursor has been moved to the beginning of the line.
I am under linux.
Just to add more info, if we do a space in the line it's also breaking the completion to remove the trailing space.
Oh, I found the problem.
I am using the files.trimTrailingWhitespace: true
that causing the problem because if I set it to false it's ok.
It's was working before, so I think it a bug.
If I'm understanding correctly, I can't seem to reproduce the problem. Here I setup a function like yours, type the member name, press enter, and the indentation doesn't get messed up. I try it with a dot, no indentation seems to get messed up:
I'm on linux also, vscode 0.10.1.
Ok, I will check if I have the lates version of VSCode. Did you turn on files.trimTrailingWhitespace: true
when doing your testing ?
No, I didn't try trimTrailingWhitespace
-- I'll test with that.
This is indeed a problem with trimTrailingWhitespaces
which makes the feature unusable. I don't see why this would happen because it should only affect trailing whitespaces.
Is there a way to distinguish completion-file-saving from normal file-saving and ignore the trailing for the former? This would also take care of actual trailing whitespace issues which I encountered in other editors before (see https://github.com/fdorg/flashdevelop/issues/604).
By the way, right now it won't even let me tab-indent, the tab is immediately deleted because the file is saved (for some reason... toplevel completion or something?).
@simn: Ah, yes, the file is saved prior to the completion call (related: https://github.com/HaxeFoundation/haxe/issues/4651) -- I was just about to ask if there was any movement on that or the function signature / comma parsing (https://github.com/HaxeFoundation/haxe/pull/4758) issues.
trimTrailingWhitespace
is a vscode setting? Perhaps we could chagne it before, and restore it after, the document.save()
calls.
I can't figure out how to modify configuration. The type WorkspaceConfiguration
seems to be read-only.
@simm File->Preferrences and you have two choices per workspace or more globally
Yes I know how to do it manually. Jeff suggested changing the setting temporarily before saving the document and I don't know how to do that.
I m working on a patch, changing before and restoring after didn't do anything
I'm curious how you changed that because all I see on the configuration is get
and has
.
yes...
The vscode API indeed only has get
and has
: https://code.visualstudio.com/docs/extensionAPI/vscode-api#WorkspaceConfiguration
Of course, ideally we wouldn't have to save files as part of the completion flow. ;)
Why have I never run into this? Are you guys setting this preference manually?
Yes, I use it in every IDE/editor because you get stupid diffs otherwise.
Got it. So perhaps we could implement an extension-level preference that does the same thing, but is aware of the completion auto-save issue. Perhaps with workspace.onDidSaveTextDocument
?
That what i was thinking until configuration can be writable...
Maybe that's indeed necessary. However, it's still strange that VS Code removed all whitespaces on a line, not just trailing ones. Might be a bug on their end?
There is another problem for now there is not a pre-event present before saving https://github.com/Microsoft/vscode/issues/239
Why do we need that? We manually call document.save()
in HaxeContext, so whatever code you want to execute you can put there.