Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions vscode/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ async def offset_at(self, position: Position) -> TextLine:
async def position_at(self, offset: int) -> Position:
raise NotImplementedError

async def replace(self, range: Range, text: str) -> None:
s = range.start
e = range.end
escaped_text = json.dumps(text)[1:-1].replace("'", "\\'")
code = (
self._editor_code
+ "editor.edit(editBuilder => {"
+ f" let range = new vscode.Range({s.line}, {s.character}, {e.line}, {e.character});".strip()
+ f" editBuilder.replace(range, '{escaped_text}');".strip()
+ "})"
)
return await self.ws.run_code(code, wait_for_response=False, thenable=False)

async def save(self):
raise NotImplementedError

Expand Down