[vscode] pass selectedText to shortcut commands
This commit is contained in:
@@ -74,9 +74,12 @@
|
||||
(awaitLet [kissStr (inputBox)]
|
||||
(infoMessage (Std.string (evalString kissStr)))))
|
||||
|
||||
(defun :Void runCommand [&opt command]
|
||||
(defun :Void runCommand [&opt command] (_runCommand command))
|
||||
|
||||
(defun :Void _runCommand [&opt command inputText]
|
||||
(unless inputText (set inputText (selectedText)))
|
||||
(if command
|
||||
{(set lastCommand command) ((dictGet commands command) (selectedText))}
|
||||
{(set lastCommand command) ((dictGet commands command) inputText)}
|
||||
(let [commandList
|
||||
(for description (commands.keys)
|
||||
(object
|
||||
@@ -88,7 +91,7 @@
|
||||
(awaitLet [chosenCommand (quickPick commandList)]
|
||||
(when chosenCommand
|
||||
(set lastCommand chosenCommand.label)
|
||||
((dictGet commands chosenCommand.label) (selectedText)))))))
|
||||
((dictGet commands chosenCommand.label) inputText))))))
|
||||
|
||||
(defun :Void runLastCommand [&opt _]
|
||||
(if lastCommand
|
||||
@@ -97,6 +100,9 @@
|
||||
|
||||
(defvar &mut :vscode.WebviewPanel shortcutPanel null)
|
||||
(defun :Void showShortcutPanel [&opt :Map<String,ShortcutKey> prefixMap]
|
||||
// Preserve the selected text and focused document before opening the webview:
|
||||
(let [inputText (selectedText)
|
||||
document .document activeTextEditor]
|
||||
// When called without a prefixMap, if a shortcut panel is still open, close it and start over:
|
||||
(unless prefixMap
|
||||
(when shortcutPanel
|
||||
@@ -121,9 +127,9 @@
|
||||
((Final command)
|
||||
(shortcutPanel.dispose)
|
||||
// TODO restore focus to previous frame first
|
||||
(runCommand command)))}
|
||||
(_runCommand command inputText)))}
|
||||
{(warningMessage "$key is not mapped to a shortcut in this context")(return)}))))
|
||||
(set shortcutPanel.webview.html (shortcutPanelHtml prefixMap)))
|
||||
(set shortcutPanel.webview.html (shortcutPanelHtml prefixMap))))
|
||||
|
||||
(defun shortcutPanelHtml [:Map<String,ShortcutKey> prefixMap]
|
||||
(let [shortcutParagraphs
|
||||
|
||||
Reference in New Issue
Block a user