Open wojtekmaj opened 4 years ago
Would be really handy for tidying up trivial linting errors.
Hi all, as I understand builtin Move Line Down
/ Move Line Up
have only language configuration understanding for indentation, but overall its just a text operation. They don't communicate with extensions and don't have any deep knowledge of the language. Of course, builtin JSON extension can detect line moves, but adding additional edits after line moves will pollute the undo stack.
Much easier solution for me was to make an extension: Move Statement that can manage commas in JSON & JS after moving statements (yes, it moves whole statements instead of lines, but now I can't imagine a case where I need to move lines specifically in JSON).
We already have API to help vscode do selection: SelectionRangeProvider
. I can imagine of similar API like MoveLinesProvider to help vscode adjust the text contents after moving lines action but before inserting it into the editor. Cases are handling indentation by extension and things like commas.
Some files like JSON or pre-ES6 JavaScript files don't allow trailing commas, so moving last line in a block up or moving other line to the bottom causes these files to be corrupted and in a need of manual editing.
Now, I press option+↑ and...
Current behavior
...oh no! two errors!
Expected behavior
Everything good!