Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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