Skip to content

Commit b380da4

Browse files
authored
Merge pull request #184491 from microsoft/joh/fix4354
do not auto finish session when inline chat widgets have focus
2 parents 380636e + 4e53a02 commit b380da4

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts

+4
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
307307
return range.getStartPosition();
308308
}
309309

310+
hasFocus() {
311+
return this.domNode.contains(dom.getActiveElement());
312+
}
313+
310314
protected _isShowing: boolean = false;
311315

312316
show(rangeOrPos: IRange | IPosition, heightInLines: number): void {

src/vs/workbench/contrib/debug/browser/exceptionWidget.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class ExceptionWidget extends ZoneWidget {
122122
this.container?.focus();
123123
}
124124

125-
hasFocus(): boolean {
125+
override hasFocus(): boolean {
126126
return dom.isAncestor(document.activeElement, this.container);
127127
}
128128
}

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class InteractiveEditorController implements IEditorContribution {
281281
}));
282282

283283
this._sessionStore.add(this._editor.onDidChangeModelContent(e => {
284-
if (this._ignoreModelContentChanged) {
284+
if (this._ignoreModelContentChanged || this._strategy?.hasFocus()) {
285285
return;
286286
}
287287

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorStrategies.ts

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export abstract class EditModeStrategy {
4242
abstract renderChanges(response: EditResponse): Promise<void>;
4343

4444
abstract toggleDiff(): void;
45+
46+
abstract hasFocus(): boolean;
4547
}
4648

4749
export class PreviewStrategy extends EditModeStrategy {
@@ -128,6 +130,10 @@ export class PreviewStrategy extends EditModeStrategy {
128130
toggleDiff(): void {
129131
// nothing to do
130132
}
133+
134+
hasFocus(): boolean {
135+
return this._widget.hasFocus();
136+
}
131137
}
132138

133139
class InlineDiffDecorations {
@@ -331,6 +337,10 @@ export class LiveStrategy extends EditModeStrategy {
331337
}
332338
this._widget.updateStatus(message);
333339
}
340+
341+
hasFocus(): boolean {
342+
return this._widget.hasFocus();
343+
}
334344
}
335345

336346
export class LivePreviewStrategy extends LiveStrategy {
@@ -389,6 +399,10 @@ export class LivePreviewStrategy extends LiveStrategy {
389399
}
390400
scrollState.restore(this._editor);
391401
}
402+
403+
override hasFocus(): boolean {
404+
return super.hasFocus() || this._diffZone.hasFocus() || this._previewZone.hasFocus();
405+
}
392406
}
393407

394408
function showSingleCreateFile(accessor: ServicesAccessor, edit: EditResponse) {

src/vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1414
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
1515
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';
1616
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
17-
import { Dimension, addDisposableListener, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
17+
import { Dimension, addDisposableListener, getActiveElement, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
1818
import { Emitter, Event, MicrotaskEmitter } from 'vs/base/common/event';
1919
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
2020
import { ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditorWidget';
@@ -502,6 +502,10 @@ export class InteractiveEditorWidget {
502502
this._inputEditor.focus();
503503
}
504504

505+
hasFocus() {
506+
return this.domNode.contains(getActiveElement());
507+
}
508+
505509
updateMarkdownMessageExpansionState(expand: boolean) {
506510
this._ctxMessageCropState.set(expand ? 'expanded' : 'cropped');
507511
this._elements.message.style.webkitLineClamp = expand ? '10' : '3';

src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class DirtyDiffWidget extends PeekViewWidget {
467467
this.editor.revealLineInCenterIfOutsideViewport(range.endLineNumber, ScrollType.Smooth);
468468
}
469469

470-
hasFocus(): boolean {
470+
override hasFocus(): boolean {
471471
return this.diffEditor.hasTextFocus();
472472
}
473473

0 commit comments

Comments
 (0)