Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not auto finish session when inline chat widgets have focus #184491

Merged
merged 2 commits into from Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
Expand Up @@ -307,6 +307,10 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
return range.getStartPosition();
}

hasFocus() {
return this.domNode.contains(dom.getActiveElement());
}

protected _isShowing: boolean = false;

show(rangeOrPos: IRange | IPosition, heightInLines: number): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/exceptionWidget.ts
Expand Up @@ -122,7 +122,7 @@ export class ExceptionWidget extends ZoneWidget {
this.container?.focus();
}

hasFocus(): boolean {
override hasFocus(): boolean {
return dom.isAncestor(document.activeElement, this.container);
}
}
Expand Up @@ -281,7 +281,7 @@ export class InteractiveEditorController implements IEditorContribution {
}));

this._sessionStore.add(this._editor.onDidChangeModelContent(e => {
if (this._ignoreModelContentChanged) {
if (this._ignoreModelContentChanged || this._strategy?.hasFocus()) {
return;
}

Expand Down
Expand Up @@ -42,6 +42,8 @@ export abstract class EditModeStrategy {
abstract renderChanges(response: EditResponse): Promise<void>;

abstract toggleDiff(): void;

abstract hasFocus(): boolean;
}

export class PreviewStrategy extends EditModeStrategy {
Expand Down Expand Up @@ -128,6 +130,10 @@ export class PreviewStrategy extends EditModeStrategy {
toggleDiff(): void {
// nothing to do
}

hasFocus(): boolean {
return this._widget.hasFocus();
}
}

class InlineDiffDecorations {
Expand Down Expand Up @@ -331,6 +337,10 @@ export class LiveStrategy extends EditModeStrategy {
}
this._widget.updateStatus(message);
}

hasFocus(): boolean {
return this._widget.hasFocus();
}
}

export class LivePreviewStrategy extends LiveStrategy {
Expand Down Expand Up @@ -389,6 +399,10 @@ export class LivePreviewStrategy extends LiveStrategy {
}
scrollState.restore(this._editor);
}

override hasFocus(): boolean {
return super.hasFocus() || this._diffZone.hasFocus() || this._previewZone.hasFocus();
}
}

function showSingleCreateFile(accessor: ServicesAccessor, edit: EditResponse) {
Expand Down
Expand Up @@ -14,7 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, IInteractiveEditorSlashCommand, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK, ACTION_ACCEPT_CHANGES } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
import { Dimension, addDisposableListener, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
import { Dimension, addDisposableListener, getActiveElement, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
import { Emitter, Event, MicrotaskEmitter } from 'vs/base/common/event';
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
import { ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditorWidget';
Expand Down Expand Up @@ -502,6 +502,10 @@ export class InteractiveEditorWidget {
this._inputEditor.focus();
}

hasFocus() {
return this.domNode.contains(getActiveElement());
}

updateMarkdownMessageExpansionState(expand: boolean) {
this._ctxMessageCropState.set(expand ? 'expanded' : 'cropped');
this._elements.message.style.webkitLineClamp = expand ? '10' : '3';
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
Expand Up @@ -467,7 +467,7 @@ class DirtyDiffWidget extends PeekViewWidget {
this.editor.revealLineInCenterIfOutsideViewport(range.endLineNumber, ScrollType.Smooth);
}

hasFocus(): boolean {
override hasFocus(): boolean {
return this.diffEditor.hasTextFocus();
}

Expand Down