TextEditor: improve sort selected lines

Try to get a sensible scope when there is no selection when sorting
lines.

Use the indent level of the current block and select all blocks that are
not empty with the same indent level around that block before sorting
the lines.

Change-Id: I68cbd95f95a0cc4425a0339b992225c3946a6858
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
David Schulz
2023-10-23 13:38:10 +02:00
parent 30ef90c322
commit 2e93051aaf
5 changed files with 70 additions and 44 deletions

View File

@@ -15,7 +15,7 @@ def main():
"visible='1' window=':Qt Creator_Core::Internal::MainWindow'}", 3000)
placeCursorToLine(editor, "bbb")
invokeMenuItem("Edit", "Select All")
invokeMenuItem("Edit", "Advanced", "Sort Selected Lines")
invokeMenuItem("Edit", "Advanced", "Sort Lines")
test.verify(waitFor("str(editor.plainText) == sorted", 2000),
"Verify that sorted text\n%s\nmatches the expected text\n%s" % (editor.plainText, sorted))
invokeMenuItem('File', 'Revert "unsorted.txt" to Saved')