mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Immediately snooze on pressing snooze (#253641)
immidiately snooze when pressing snooze
This commit is contained in:
committed by
GitHub
parent
d63c9dd28e
commit
9f7ea0588d
@@ -83,26 +83,31 @@ export class InlineCompletionsService extends Disposable implements IInlineCompl
|
||||
}
|
||||
|
||||
setSnoozeDuration(durationMs: number): void {
|
||||
if (durationMs < 0) {
|
||||
throw new BugIndicatingError(`Invalid snooze duration: ${durationMs}. Duration must be non-negative.`);
|
||||
}
|
||||
if (durationMs === 0) {
|
||||
this.cancelSnooze();
|
||||
return;
|
||||
}
|
||||
|
||||
const wasSnoozing = this.isSnoozing();
|
||||
this._snoozeTimeEnd = Date.now() + durationMs;
|
||||
const isSnoozing = this.isSnoozing();
|
||||
|
||||
if (wasSnoozing !== isSnoozing) {
|
||||
this._onDidChangeIsSnoozing.fire(isSnoozing);
|
||||
if (!wasSnoozing) {
|
||||
this._onDidChangeIsSnoozing.fire(true);
|
||||
}
|
||||
|
||||
if (isSnoozing) {
|
||||
this._timer.cancelAndSet(
|
||||
() => {
|
||||
if (!this.isSnoozing()) {
|
||||
this._onDidChangeIsSnoozing.fire(false);
|
||||
} else {
|
||||
throw new BugIndicatingError('Snooze timer did not fire as expected');
|
||||
}
|
||||
},
|
||||
this.snoozeTimeLeft + 1,
|
||||
);
|
||||
}
|
||||
this._timer.cancelAndSet(
|
||||
() => {
|
||||
if (!this.isSnoozing()) {
|
||||
this._onDidChangeIsSnoozing.fire(false);
|
||||
} else {
|
||||
throw new BugIndicatingError('Snooze timer did not fire as expected');
|
||||
}
|
||||
},
|
||||
this.snoozeTimeLeft + 1,
|
||||
);
|
||||
}
|
||||
|
||||
isSnoozing(): boolean {
|
||||
|
||||
+1
-4
@@ -37,7 +37,6 @@ import { ObservableContextKeyService } from '../utils.js';
|
||||
import { InlineCompletionsView } from '../view/inlineCompletionsView.js';
|
||||
import { inlineSuggestCommitId } from './commandIds.js';
|
||||
import { InlineCompletionContextKeys } from './inlineCompletionContextKeys.js';
|
||||
import { IInlineCompletionsService } from '../../../../browser/services/inlineCompletionsService.js';
|
||||
|
||||
export class InlineCompletionsController extends Disposable {
|
||||
private static readonly _instances = new Set<InlineCompletionsController>();
|
||||
@@ -96,7 +95,6 @@ export class InlineCompletionsController extends Disposable {
|
||||
@IAccessibilitySignalService private readonly _accessibilitySignalService: IAccessibilitySignalService,
|
||||
@IKeybindingService private readonly _keybindingService: IKeybindingService,
|
||||
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
|
||||
@IInlineCompletionsService private readonly _inlineCompletionsService: IInlineCompletionsService,
|
||||
) {
|
||||
super();
|
||||
this._editorObs = observableCodeEditor(this.editor);
|
||||
@@ -112,8 +110,7 @@ export class InlineCompletionsController extends Disposable {
|
||||
this._contextKeyService.onDidChangeContext,
|
||||
() => this._contextKeyService.getContext(this.editor.getDomNode()).getValue('editorDictation.inProgress') === true
|
||||
);
|
||||
const isSnoozing = observableFromEvent(this, this._inlineCompletionsService.onDidChangeIsSnoozing, () => this._inlineCompletionsService.isSnoozing());
|
||||
this._enabled = derived(this, reader => this._enabledInConfig.read(reader) && !isSnoozing.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._editorDictationInProgress.read(reader)));
|
||||
this._enabled = derived(this, reader => this._enabledInConfig.read(reader) && (!this._isScreenReaderEnabled.read(reader) || !this._editorDictationInProgress.read(reader)));
|
||||
this._debounceValue = this._debounceService.for(
|
||||
this._languageFeaturesService.inlineCompletionsProvider,
|
||||
'InlineCompletionsDebounce',
|
||||
|
||||
@@ -46,6 +46,7 @@ import { SuggestItemInfo } from './suggestWidgetAdapter.js';
|
||||
import { TextModelEditReason, EditReasons } from '../../../../common/textModelEditReason.js';
|
||||
import { ICodeEditorService } from '../../../../browser/services/codeEditorService.js';
|
||||
import { InlineCompletionViewData, InlineCompletionViewKind } from '../view/inlineEdits/inlineEditsViewInterface.js';
|
||||
import { IInlineCompletionsService } from '../../../../browser/services/inlineCompletionsService.js';
|
||||
|
||||
export class InlineCompletionsModel extends Disposable {
|
||||
private readonly _source;
|
||||
@@ -90,6 +91,7 @@ export class InlineCompletionsModel extends Disposable {
|
||||
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService,
|
||||
@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
|
||||
@ICodeEditorService private readonly _codeEditorService: ICodeEditorService,
|
||||
@IInlineCompletionsService inlineCompletionsService: IInlineCompletionsService
|
||||
) {
|
||||
super();
|
||||
this.primaryPosition = derived(this, reader => this._positions.read(reader)[0] ?? new Position(1, 1));
|
||||
@@ -111,6 +113,11 @@ export class InlineCompletionsModel extends Disposable {
|
||||
this._inlineEditsEnabled = this._editorObs.getOption(EditorOption.inlineSuggest).map(v => !!v.edits.enabled);
|
||||
this._inlineEditsShowCollapsedEnabled = this._editorObs.getOption(EditorOption.inlineSuggest).map(s => s.edits.showCollapsed);
|
||||
this._triggerCommandOnProviderChange = this._editorObs.getOption(EditorOption.inlineSuggest).map(s => s.experimental.triggerCommandOnProviderChange);
|
||||
this._register(inlineCompletionsService.onDidChangeIsSnoozing((isSnoozing) => {
|
||||
if (isSnoozing) {
|
||||
this.stop();
|
||||
}
|
||||
}));
|
||||
|
||||
this._lastShownInlineCompletionInfo = undefined;
|
||||
this._lastAcceptedInlineCompletionInfo = undefined;
|
||||
@@ -183,7 +190,8 @@ export class InlineCompletionsModel extends Disposable {
|
||||
this._onlyRequestInlineEditsSignal.read(reader);
|
||||
this._forceUpdateExplicitlySignal.read(reader);
|
||||
this._fetchSpecificProviderSignal.read(reader);
|
||||
const shouldUpdate = (this._enabled.read(reader) && this._selectedSuggestItem.read(reader)) || this._isActive.read(reader);
|
||||
const shouldUpdate = ((this._enabled.read(reader) && this._selectedSuggestItem.read(reader)) || this._isActive.read(reader))
|
||||
&& (!inlineCompletionsService.isSnoozing() || changeSummary.inlineCompletionTriggerKind === InlineCompletionTriggerKind.Explicit);
|
||||
if (!shouldUpdate) {
|
||||
this._source.cancelUpdate();
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user