Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active May 11, 2022 20:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/08ec3ae2af5963a4a03cd8e0873c918d to your computer and use it in GitHub Desktop.
Save borkdude/08ec3ae2af5963a4a03cd8e0873c918d to your computer and use it in GitHub Desktop.
Increment number on line in joyride
(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