mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
relayout when zone widget width changes (#206963)
* inline - change the input editor to be a normal editor, not an embedded one https://github.com/microsoft/vscode/issues/206940 * relayout when zone widget width changes
This commit is contained in:
parent
6bdee9d1e3
commit
b92a5dd3f0
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { Codicon } from 'vs/base/common/codicons';
|
||||
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction2 } from 'vs/editor/browser/editorExtensions';
|
||||
import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/embeddedDiffEditorWidget';
|
||||
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
|
||||
|
@ -31,6 +31,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
|||
import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions';
|
||||
import { registerIcon } from 'vs/platform/theme/common/iconRegistry';
|
||||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
|
||||
CommandsRegistry.registerCommandAlias('interactiveEditor.start', 'inlineChat.start');
|
||||
CommandsRegistry.registerCommandAlias('interactive.acceptChanges', ACTION_ACCEPT_CHANGES);
|
||||
|
@ -129,10 +130,28 @@ export abstract class AbstractInlineChatAction extends EditorAction2 {
|
|||
}
|
||||
|
||||
override runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]) {
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const logService = accessor.get(ILogService);
|
||||
|
||||
let ctrl = InlineChatController.get(editor);
|
||||
if (!ctrl) {
|
||||
const { activeTextEditorControl } = editorService;
|
||||
if (isCodeEditor(activeTextEditorControl)) {
|
||||
editor = activeTextEditorControl;
|
||||
} else if (isDiffEditor(activeTextEditorControl)) {
|
||||
editor = activeTextEditorControl.getModifiedEditor();
|
||||
}
|
||||
ctrl = InlineChatController.get(editor);
|
||||
}
|
||||
|
||||
if (!ctrl) {
|
||||
logService.warn('[IE] NO controller found for action', this.desc.id, editor.getModel()?.uri);
|
||||
return;
|
||||
}
|
||||
|
||||
if (editor instanceof EmbeddedCodeEditorWidget) {
|
||||
editor = editor.getParentEditor();
|
||||
}
|
||||
const ctrl = InlineChatController.get(editor);
|
||||
if (!ctrl) {
|
||||
for (const diffEditor of accessor.get(ICodeEditorService).listDiffEditors()) {
|
||||
if (diffEditor.getOriginalEditor() === editor || diffEditor.getModifiedEditor() === editor) {
|
||||
|
|
|
@ -18,7 +18,7 @@ import 'vs/css!./inlineChat';
|
|||
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
|
||||
import { IActiveCodeEditor, ICodeEditor, IDiffEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget';
|
||||
import { CodeEditorWidget, ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditor/codeEditorWidget';
|
||||
import { AccessibleDiffViewer, IAccessibleDiffViewerModel } from 'vs/editor/browser/widget/diffEditor/components/accessibleDiffViewer';
|
||||
import { EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/embeddedDiffEditorWidget';
|
||||
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
|
||||
|
@ -280,7 +280,7 @@ export class InlineChatWidget {
|
|||
])
|
||||
};
|
||||
|
||||
this._inputEditor = <IActiveCodeEditor>this._instantiationService.createInstance(EmbeddedCodeEditorWidget, this._elements.editor, _inputEditorOptions, codeEditorWidgetOptions, this._parentEditor);
|
||||
this._inputEditor = <IActiveCodeEditor>this._instantiationService.createInstance(CodeEditorWidget, this._elements.editor, _inputEditorOptions, codeEditorWidgetOptions);
|
||||
this._updateAriaLabel();
|
||||
this._store.add(this._inputEditor);
|
||||
this._store.add(this._inputEditor.onDidChangeModelContent(() => this._onDidChangeInput.fire(this)));
|
||||
|
|
|
@ -114,6 +114,12 @@ export class InlineChatZoneWidget extends ZoneWidget {
|
|||
return this.widget.getHeight() / lineHeight;
|
||||
}
|
||||
|
||||
protected override _onWidth(_widthInPixel: number): void {
|
||||
if (this._dimension) {
|
||||
this._doLayout(this._dimension.height);
|
||||
}
|
||||
}
|
||||
|
||||
protected override _relayout() {
|
||||
if (this._dimension) {
|
||||
this._doLayout(this._dimension.height);
|
||||
|
|
Loading…
Reference in a new issue