Skip to content

Commit

Permalink
fix(DocumentWatcher): use Workspace.applyEdit for applying changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila committed Nov 26, 2024
1 parent b86ebd4 commit c4c88a8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/DocumentWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TextEditorOptions,
window,
workspace,
WorkspaceEdit,
} from 'vscode'
import {
InsertFinalNewline,
Expand Down Expand Up @@ -81,12 +82,14 @@ export default class DocumentWatcher {
e.document,
e.reason,
)
e.waitUntil(transformations)
if (selections.length) {
const edits = await transformations
if (activeEditor && edits.length) {
activeEditor.selections = selections
}

const workspaceEdit = new WorkspaceEdit()
const textEdits = await transformations
workspaceEdit.set(e.document.uri, textEdits)
await workspace.applyEdit(workspaceEdit)

if (activeEditor && textEdits.length) {
activeEditor.selections = selections
}
}),
)
Expand Down

0 comments on commit c4c88a8

Please sign in to comment.