Skip to content

Commit

Permalink
dispose event
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Aug 9, 2023
1 parent cffd4bc commit 205aa50
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/specialCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ export default () => {

onCompletionAcceptedOverride.value = () => {}
const { ranges, text } = await new Promise<{ text: string; ranges: vscode.Range[] }>(resolve => {
vscode.workspace.onDidChangeTextDocument(({ document, contentChanges }) => {
const { dispose } = vscode.workspace.onDidChangeTextDocument(({ document, contentChanges }) => {
if (document !== editor.document || contentChanges.length === 0) return
const ranges = contentChanges.map(
change => new vscode.Range(change.range.start, offsetPosition(document, change.range.start, change.text.length)),
)
dispose()
resolve({ ranges, text: contentChanges[0]!.text })
})
void vscode.commands.executeCommand('acceptSelectedSuggestion')
Expand Down

0 comments on commit 205aa50

Please sign in to comment.