diff --git a/src/vs/editor/browser/observableCodeEditor.ts b/src/vs/editor/browser/observableCodeEditor.ts index d8607ae319a..3633d4cac45 100644 --- a/src/vs/editor/browser/observableCodeEditor.ts +++ b/src/vs/editor/browser/observableCodeEditor.ts @@ -14,7 +14,7 @@ import { Selection } from '../common/core/selection.js'; import { ICursorSelectionChangedEvent } from '../common/cursorEvents.js'; import { IModelDeltaDecoration, ITextModel } from '../common/model.js'; import { IModelContentChangedEvent } from '../common/textModelEvents.js'; -import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IOverlayWidget, IOverlayWidgetPosition } from './editorBrowser.js'; +import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IOverlayWidget, IOverlayWidgetPosition, IPasteEvent } from './editorBrowser.js'; import { Point } from './point.js'; /** @@ -94,6 +94,16 @@ export class ObservableCodeEditor extends Disposable { } })); + this._register(this.editor.onDidPaste((e) => { + this._beginUpdate(); + try { + this._forceUpdate(); + this.onDidPaste.trigger(this._currentTransaction, e); + } finally { + this._endUpdate(); + } + })); + this._register(this.editor.onDidChangeModelContent(e => { this._beginUpdate(); try { @@ -213,6 +223,7 @@ export class ObservableCodeEditor extends Disposable { public readonly cursorLineNumber = derived(this, reader => this.cursorPosition.read(reader)?.lineNumber ?? null); public readonly onDidType = observableSignal(this); + public readonly onDidPaste = observableSignal(this); public readonly scrollTop = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollTop()); public readonly scrollLeft = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollLeft()); diff --git a/src/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.ts b/src/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.ts index 7c7e4495719..79fdfb85afd 100644 --- a/src/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.ts +++ b/src/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.ts @@ -140,6 +140,12 @@ export class InlineCompletionsController extends Disposable { } })); + this._register(runOnChange(this._editorObs.onDidPaste, (_value, _changes) => { + if (this._enabled.get()) { + this.model.get()?.trigger(); + } + })); + this._register(this._commandService.onDidExecuteCommand((e) => { // These commands don't trigger onDidType. const commands = new Set([