You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I.e. they expect a [vscode.TextEditor](https://code.visualstudio.com/api/references/vscode-api#TextEditor) – defaulting to the currently active editor – and a [vscode.Position](https://code.visualstudio.com/api/references/vscode-api#Position) – defaulting to the current active position in the editor (or the first active position if multiple selections/positions exist, and will return a tuple with the range, and the text for the piece of interest requested.
357
+
They can be called in three ways:
358
+
359
+
***No arguments**: uses the active text editor’s document and cursor position.
360
+
***A `TextEditor`**: uses its document and primary cursor position (or the given `position` if provided).
361
+
***A `TextDocument` + `Position`**: uses them directly — no visible editor required. This is useful for programmatic/API usage where you have a document reference but no open editor tab.
362
+
363
+
All variants return a tuple with the range and the text for the piece of interest requested.
358
364
359
365
!!! Note "Custom REPL Commands"
360
366
The `ranges` function have corresponding [REPL Snippets/Commands](custom-commands.md) substitution variables. It is the same implementation functions used in both cases.
@@ -421,12 +438,14 @@ The `editor` module has facilites (well, a facility, so far) for editing Clojure
421
438
422
439
### `editor.replace()`
423
440
424
-
With `editor.replace()` you can replace a range in a Clojure editor with new text. The arguments are:
441
+
With `editor.replace()` you can replace a range in a Clojure document with new text. The arguments are:
425
442
426
-
*`editor`, a `vscode.TextEditor`
443
+
*`editorOrDocument`, a `vscode.TextEditor` or a `vscode.TextDocument`
427
444
*`range`, a `vscode.Range`
428
445
*`newText`, a string
429
446
447
+
When a `TextEditor` is provided, the edit uses `TextEditor.edit()` with undo grouping and formatting. When a `TextDocument` is provided, the edit uses `WorkspaceEdit` — no visible editor is required, making it suitable for programmatic edits from other extensions.
448
+
430
449
=== "Joyride"
431
450
432
451
```clojure
@@ -437,6 +456,19 @@ With `editor.replace()` you can replace a range in a Clojure editor with new tex
437
456
(println "Error replacing text:" e))))
438
457
```
439
458
459
+
=== "Joyride (editor-free)"
460
+
461
+
```clojure
462
+
;; Edit a document without opening it in an editor
0 commit comments