mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
parent
d0aceadf96
commit
f0676fb01a
|
@ -11,7 +11,8 @@ import { equals } from 'vs/base/common/arrays';
|
|||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { Disposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IObservable, autorun, autorunWithStore, derived, observableFromEvent } from 'vs/base/common/observable';
|
||||
import { IObservable, autorun, autorunWithStore, derived, derivedObservableWithCache, observableFromEvent } from 'vs/base/common/observable';
|
||||
import { derivedWithStore } from 'vs/base/common/observableInternal/derived';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import 'vs/css!./inlineCompletionsHintsWidget';
|
||||
|
@ -71,26 +72,36 @@ export class InlineCompletionsHintsWidget extends Disposable {
|
|||
return;
|
||||
}
|
||||
|
||||
const contentWidget = store.add(this.instantiationService.createInstance(
|
||||
InlineSuggestionHintsContentWidget,
|
||||
this.editor,
|
||||
true,
|
||||
this.position,
|
||||
model.selectedInlineCompletionIndex,
|
||||
model.inlineCompletionsCount,
|
||||
model.activeCommands,
|
||||
));
|
||||
editor.addContentWidget(contentWidget);
|
||||
store.add(toDisposable(() => editor.removeContentWidget(contentWidget)));
|
||||
const contentWidgetValue = derivedWithStore((reader, store) => {
|
||||
const contentWidget = store.add(this.instantiationService.createInstance(
|
||||
InlineSuggestionHintsContentWidget,
|
||||
this.editor,
|
||||
true,
|
||||
this.position,
|
||||
model.selectedInlineCompletionIndex,
|
||||
model.inlineCompletionsCount,
|
||||
model.activeCommands,
|
||||
));
|
||||
editor.addContentWidget(contentWidget);
|
||||
store.add(toDisposable(() => editor.removeContentWidget(contentWidget)));
|
||||
|
||||
store.add(autorun(reader => {
|
||||
/** @description request explicit */
|
||||
const position = this.position.read(reader);
|
||||
if (!position) {
|
||||
return;
|
||||
}
|
||||
if (model.lastTriggerKind.read(reader) !== InlineCompletionTriggerKind.Explicit) {
|
||||
model.triggerExplicitly();
|
||||
}
|
||||
}));
|
||||
return contentWidget;
|
||||
});
|
||||
|
||||
const hadPosition = derivedObservableWithCache(this, (reader, lastValue) => !!this.position.read(reader) || !!lastValue);
|
||||
store.add(autorun(reader => {
|
||||
/** @description request explicit */
|
||||
const position = this.position.read(reader);
|
||||
if (!position) {
|
||||
return;
|
||||
}
|
||||
if (model.lastTriggerKind.read(reader) !== InlineCompletionTriggerKind.Explicit) {
|
||||
model.triggerExplicitly();
|
||||
if (hadPosition.read(reader)) {
|
||||
contentWidgetValue.read(reader);
|
||||
}
|
||||
}));
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue