Skip to content

Commit

Permalink
Merge pull request #184491 from microsoft/joh/fix4354
Browse files Browse the repository at this point in the history
do not auto finish session when inline chat widgets have focus
  • Loading branch information
jrieken committed Jun 7, 2023
2 parents 380636e + 4e53a02 commit b380da4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit b380da4

Please sign in to comment.