Arduino Continue to Next Line Ide
I am able to reproduce this on my Linux machine, but not on my Windows machine.
@Willem43T did some investigation and shared their valuable findings on the Arduino Forum:
https://forum.arduino.cc/t/cursor-jumping-problem/1023535
I'll document what I have learned about the issue here:
To reproduce
- Select File > Preferences... from the Arduino IDE menus.
- Check the box next to "☐ Auto save".
ⓘ I use Auto save for this demo because it produces the more disruptive behavior as reported in the issue, but the bug occurs even on manual save when Auto Save is disabled. - Click the OK button.
- Open the "Command Palette" via the Ctrl + Shift + P ( Command + Shift + P for macOS users) keyboard shortcut.
- Select the "Preferences: Open Settings (UI)" command.
- In the "Search Settings" field, type
editor.trimAutoWhitespace - Check the checkbox next to "☐ Remove trailing auto inserted whitespace."
ⓘ This is the default, the instructions are only ensuring you don't have a custom setting. - In the "Search Settings" field, type
files.trimTrailingWhitespace - Uncheck the checkbox next to "
☑When enabled, will trim trailing whitespace when saving a file."
ⓘ This is the default, the instructions are only ensuring you don't have a custom setting. - Create the following sketch code:
void setup() { // indented line } void loop() {}
- Place the cursor at the end of line 2.
- Press Enter
🙂 Whitespace is automatically inserted at the start of the new line to indent it to the same level as the previous one:
- Wait for the Auto Save operation to complete, as indicated by the disappearance of the ⬤ indicator from the right side of the sketch tab.
ⓘ I set "editor.renderWhitespace": "all" for these screenshots in order to make the whitespace visible as a "•".
Expected behavior
In short: the VS Code behavior. This is the behavior the Arduino IDE has on my Windows machine.
I expect the Arduino IDE to work exactly like that, and to work that way consistently.
I'll provide the exact descriptions of the expected behavior of each of the related settings.
editor.trimAutoWhitespace
Default: true
Remove automatically inserted whitespace when it would end up as trailing whitespace.
This feature is completely unrelated to saving. Trimming is done on the fly while the user is editing, even when auto save is disabled.
- Open the "Command Palette" via the Ctrl + Shift + P ( Command + Shift + P for macOS users) keyboard shortcut.
- Select the "Preferences: Open Settings (UI)" command.
- In the "Search Settings" field, type
editor.trimAutoWhitespace - Check the checkbox next to "☐ Remove trailing auto inserted whitespace."
- Create the following sketch code:
void setup() { // indented line } void loop() {}
- Place the cursor at the end of line 2.
- Press Enter
Whitespace is automatically inserted at the start of the new line to indent it to the same level as the previous one:
- Press Enter
The automatically inserted whitespace on the previous line is removed:
files.trimTrailingWhitespace
Default: false
Remove all trailing whitespace on explicit save (when the user triggers a save via File > Save).
Whitespace is not trimmed on auto save.
-
Select File > Preferences... from the Arduino IDE menus.
-
Check the box next to "☐ Auto save".
-
Click the OK button.
-
Open the "Command Palette" via the Ctrl + Shift + P ( Command + Shift + P for macOS users) keyboard shortcut.
-
Select the "Preferences: Open Settings (UI)" command.
-
In the "Search Settings" field, type
files.trimTrailingWhitespace -
Check the checkbox next to "☐ When enabled, will trim trailing whitespace when saving a file."
-
Create the following sketch code:
void setup() { // indented line } void loop() {}
-
Place the cursor at the end of line 2.
-
Press Enter
Whitespace is automatically inserted at the start of the new line to indent it to the same level as the previous one:
-
Wait for the Auto Save operation to complete, as indicated by the disappearance of the ⬤ indicator from the right side of the sketch tab.
The whitespace is not removed:
-
Select File > Save from the Arduino IDE menus.
All trailing whitespace is removed from the sketch:
Arduino IDE version
2.0.0-rc9.2.snapshot-de32bdd
Operating system
- Ubuntu 20.04 (the machine where I can reproduce bug)
- Windows 10 (the machine where I cannot reproduce bug)
Additional context
Since we have reports of this occurring on Linux, macOS, and Windows, I don't think the difference in operating systems between my two machines is the relevant factor.
I have all default Arduino IDE settings on both machines.
I am also able to reproduce the bug on my Linux machine using Theia Blueprint versions "0.25.0 (Beta)" (matching the version of Theia currently used by Arduino IDE) and "1.28.0 (Beta)" (the latest version).
I am not able to reproduce the bug on my Windows machine using Theia Blueprint.
This leads me to believe that the bug is in Eclipse Theia or one of its dependencies, not a bug in the Arduino IDE code base.
I found this similar issue in the Theia repository: eclipse-theia/theia#8718
However, that is related to the presence of an .editorconfig file. The bug occurs in sketches that do not contain such a file and I also don't have any in the parent folders. I also tried adding one to the sketch with trim_trailing_whitespace = false, and the bug still occurs. This leads me to believe that the bug is different from that described in eclipse-theia/theia#8718.
The fact that the issue occurs in Theia Blueprint, and that it occurs even after I run the "Arduino: Stop Language Server" command or when I have no board selected seems to be evidence against the previous hypothesis that this was related to the language server.
I am not able to reproduce the bug using VS Code with the same settings on my Linux machine.
As discovered by @Willem43T, the bug no longer occurs if editor.trimAutoWhitespace is set to false.
While the use of this workaround by those afflicted will mitigate the impact, I think the editor.trimAutoWhitespace feature is useful when working as intended and also provides parity with Arduino IDE 1.x, which has equivalent behavior. So I don't see globally changing the default value in the Arduino IDE code base as a viable solution for the bug.
The behavior of the bug does not match the behavior of files.trimTrailingWhitespace. Only the automatically inserted whitespace is removed. Any other trailing whitespace in the sketch is preserved.
Source: https://github.com/arduino/arduino-ide/issues/437
0 Response to "Arduino Continue to Next Line Ide"
Post a Comment