DWC 3.2, gcode editor issue
garyd9 last edited by
Conditional gcode (at least with DSF) is very sensitive to the difference between spaces and tabs for conditional blocks of code. For that reason, if the DWC gcode editor is going to autoindent on new lines, it needs to either differentiate between space and tab characters, or it needs to automatically replace 'tab' characters with spaces.
For example, assume I type the following in the gcode editor. All characters are as typed, with special keys using angled braces (ie: <backspace>, <tab>, <return>):
<tab>echo "test 1"<return>
echo "test 2"<return>
What happens above is that after the line that echo's "test 1", the gcode editor is helpfully auto-indenting the next line. However, it's NOT using a tab character to indent, and instead inserting 4 spaces. The resulting gcode LOOKS okay and with proper indenting, but it's NOT because the echo of "test 1" is preceded by a single tab character and the echo of "test 2" is preceded by 4 space characters.
This results in some very odd things happening when running conditional gcode that appears to be perfect (and debugging it isn't fun.)
Suggestion: Either the gcode editor should copy the characters used to indent the previous line, OR it should re-write TAB characters to sequences of spaces (which is probably easier than re-writing sequences of spaces to tabs.) Or, perhaps it should use it's syntax highlighting to change the background color of TAB characters to make it obvious that something is different...
Personally it think replacing tabs with 4 (or use configurable) number of spaces is probably best.
I think this does not come up as much as it might because its not normal to type a <tab> character in a browser, at least on windows, as tab moves the focus. I know DWC's code editor does allow for tab capture and insertion, but people may be conditioned not to tab in a browser!
jay_s_uk last edited by
I use tabs a lot in the gcode editor. Especially for lining up the comments.
I think it may get used more than expected, especially by coders used to using tabs for indents.
Fair enough! anyway I have logged it:
DaveA last edited by
Would there be any possibility to have the DWC use an external editor such as NotePad++? In the Arduino IDE you can elect to use any editor you like.
Thanks for pointing this out. I've got a change for DSF ready so it will treat tabs just like RRF (i.e. to add up to 4 spaces to the current indentation level). I'll try to change the new editor to auto-insert tabs if the last line contains tabs, too.