sort lines by EOL

This commit is contained in:
2024-11-12 19:09:35 -06:00
parent 978ffb8b53
commit c5c7351db3
3 changed files with 18 additions and 3 deletions

View File

@@ -65,7 +65,7 @@
"key": "Ctrl+; Ctrl+m" "key": "Ctrl+; Ctrl+m"
}, },
{ {
"command": "kiss-vscode.sortLinesSync", "command": "kiss-vscode.sortLinesSyncDefault",
"mac": "Cmd+; Cmd+s", "mac": "Cmd+; Cmd+s",
"key": "Ctrl+; Ctrl+s" "key": "Ctrl+; Ctrl+s"
} }
@@ -102,6 +102,14 @@
{ {
"title": "kiss-vscode: Sort the selected text lines using a (String,String)->Int comparator function", "title": "kiss-vscode: Sort the selected text lines using a (String,String)->Int comparator function",
"command": "kiss-vscode.sortLinesSync" "command": "kiss-vscode.sortLinesSync"
},
{
"title": "kiss-vscode: Sort the selected lines lexicographically",
"command": "kiss-vscode.sortLinesSyncDefault"
},
{
"title": "kiss-vscode: Sort the selected lines lexicographically from the end of each line",
"command": "kiss-vscode.sortLinesSyncEOL"
} }
], ],
"languages": [ "languages": [

View File

@@ -12,6 +12,7 @@ import re_flex.R;
using haxe.io.Path; using haxe.io.Path;
using StringTools; using StringTools;
using uuid.Uuid; using uuid.Uuid;
using hx.strings.Strings;
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class Main {} class Main {}

View File

@@ -30,6 +30,12 @@
(e.delete editor.selection) (e.delete editor.selection)
(e.insert editor.selection.active (lines.join "\n"))))))) (e.insert editor.selection.active (lines.join "\n")))))))
(defCommand context sortLinesSync "Sort the selected text lines using a (String,String)->Int comparator function" "C-; C-s" [] (defCommand context sortLinesSync "Sort the selected text lines using a (String,String)->Int comparator function" "" []
(awaitLet [compareFuncStr (inputEditor "sortLinesFunc.kiss" "a (String,String) -> Int function with which to sort the selected lines")] (awaitLet [compareFuncStr (inputEditor "sortLinesFunc.kiss" "a (String,String) -> Int function with which to sort the selected lines")]
(_sortLinesSync (selectedText) (if (< 0 compareFuncStr.length) (evalString compareFuncStr) Reflect.compare)))) (_sortLinesSync (selectedText) (if (< 0 compareFuncStr.length) (evalString compareFuncStr) Reflect.compare))))
(defCommand context sortLinesSyncDefault "Sort the selected lines lexicographically" "C-; C-s" []
(_sortLinesSync (selectedText) Reflect.compare))
(defCommand context sortLinesSyncEOL "Sort the selected lines lexicographically from the end of each line" "" []
(_sortLinesSync (selectedText) ->[:String s1 :String s2] (Reflect.compare (s1.reverse) (s2.reverse))))