Trigger inline edits on paste (#236584)
parent
225d1ca870
commit
5385e31b3f
|
@ -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<number | null>(this, reader => this.cursorPosition.read(reader)?.lineNumber ?? null);
|
||||
|
||||
public readonly onDidType = observableSignal<string>(this);
|
||||
public readonly onDidPaste = observableSignal<IPasteEvent>(this);
|
||||
|
||||
public readonly scrollTop = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollTop());
|
||||
public readonly scrollLeft = observableFromEvent(this.editor.onDidScrollChange, () => this.editor.getScrollLeft());
|
||||
|
|
|
@ -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([
|
||||
|
|
Loading…
Reference in New Issue