Last active
May 11, 2022 20:23
-
-
Save borkdude/08ec3ae2af5963a4a03cd8e0873c918d to your computer and use it in GitHub Desktop.
Increment number on line in joyride
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '["vscode" :as vscode] | |
'[clojure.string :as str]) | |
(defn insert-num | |
[] | |
(let [editor vscode/window.activeTextEditor | |
position (.-active (.-selection editor)) | |
doc (.-document editor) | |
line (-> (.lineAt doc position) (.-text)) | |
character (last (str/trim line)) | |
num (js/parseInt character)] | |
(when (int? num) | |
(-> (p/do (.edit editor | |
(fn [builder] | |
(.insert builder position (inc num))) | |
#js {:undoStopBefore true :undoStopAfter false})) | |
(p/catch (fn [e] | |
(js/console.error e))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment