Skip to content

Commit

Permalink
Merge pull request #113 from CodinGame/fix-placeholder
Browse files Browse the repository at this point in the history
Fix placeholder update when model changes
  • Loading branch information
CGNonofr authored Apr 30, 2024
2 parents 910edd4 + 591fc73 commit d10363c
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 d10363c

Please sign in to comment.