Here's patch which adds SCI_LINETAB and SCI_LINEBACKTAB. These force the multiline behaviour of SCI_TAB and SCI_BACKTAB and can be used to assign Ctrl+] and Ctrl+[ to indent and unindent/dedent lines like VSCode, even if there's not multiple lines selected. There's no real new code introduced.
The patch also tries to make SCI_BACKTAB's description in Scintilla.iface more accurate. The existing description makes it sounds like SCI_BACKTAB has no special behaviour if there's not multiple lines selected but it actually has.
https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/8.diff
https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/8.patch
https://github.com/jrsoftware/scintilla/pull/8/files
These may be better named to match their result like "indent" and "dedent" instead of the associated key.
I've updated the patch to use the suggested names.
Committed as [e91d19] spelt
SCI_LINEINDENT
andSCI_LINEDEDENT
. Message numbers changed.Related
Commit: [e91d19]
Thanks! Also thanks for releasing 5.5.1.
I beleive my original patch has a small mistake making it so that doing SCI_LINEINDENT with the caret and anchor at the start of the same line does nothing.
I think the fix might be to put a
if (!lineIndent)
check before this bit in Editor.cxx:Sorry for the inconvenience.
Another potential issue is that in the same case doing the indent doesnt cause the line to be selected. Not sure if it should do this or not.
The reason the line isn't selected is that lineOfAnchor equals lineCurrentPos and anchorPosOnLine = 0 so it does this code which doesn't select anything:
This made performing
SCI_LINEINDENT
twice after the line start cause the next line to move. Perhaps I applied the change wrong as it was described rather than shown as a patch.void Indent(bool forwards, bool lineTab);
does not matchvoid Editor::Indent(bool forwards, bool lineIndent)
will cause a clang-tidy readability-inconsistent-declaration-parameter-name warning.OK, [019f8b].
Related
Commit: [019f8b]
I reopened this on 2024-11-07 because of the bug reported by the feature author Martijn Laan which has not yet been fixed.