Open joeshaw opened 3 years ago
Poking at this a little bit more, this seems to be the result of editor.action.reindentselectedlines
not doing the right thing in this case.
That is the reason for this behavior. I was hoping that the document formatter of language support would improve over time. To solve this, I tried to reindent using range selection when the previous line is blank.
Note that the document formatter inserts unnecessary whitespace in blank lines. You need to set the trailing whitespace.
As an alternative, could you delete the previous line and then insert a new line in the manner that pressing "enter" does, thereby indenting to the right place? Maybe that only works for a single line and not a selection -- I almost never hit "tab" with a selection.
It's best to use Insert Line Below(editor.action.insertLineAfter), considering only when lines are added and indented. However, the problem is that the end of the block is also indented. If it is possible to switch to distinguish these cases, we can use that method.
If I have two blank lines in a row and hit tab on the second blank line, the cursor is taken back to column 1. This isn't what I expect: I want to jump to the appropriate indentation for the document, ignoring any blank lines above it. The built-in VSCode behavior of hitting enter on a blank line does jump me to the appropriate indent.
For example, take a JSON document:
On row 3, hitting tab correctly indents inline with the other JSON keys.
On row 4, hitting tab takes the cursor back to column 1. I would expect the behavior to be the same between rows 3 and 4. (Note that row 3 has to be completely blank for this to be the case: if row 3 has indentation in it, row 4 will indent to that level.)
This isn't limited to JSON documents.