Skip to content

Commit

Permalink
fix: fix placeholder update when model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Apr 30, 2024
1 parent 910edd4 commit 591fc73
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ export function addPlaceholder (
editor: monaco.editor.ICodeEditor,
placeholder: string
): monaco.IDisposable {
const disposableStore = new DisposableStore()

const widget = new PlaceholderContentWidget(editor, placeholder)

function onDidChangeModelContent (): void {
Expand All @@ -475,13 +477,14 @@ export function addPlaceholder (
}

onDidChangeModelContent()
const changeDisposable = editor.onDidChangeModelContent(() => onDidChangeModelContent())
return {
disposableStore.add(editor.onDidChangeModelContent(onDidChangeModelContent))
disposableStore.add(editor.onDidChangeModel(onDidChangeModelContent))
disposableStore.add({
dispose () {
changeDisposable.dispose()
editor.removeContentWidget(widget)
}
}
})
return disposableStore
}

export function mapClipboard (
Expand Down

0 comments on commit 591fc73

Please sign in to comment.