mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
show inline chat content widget below the selection (#208907)
* let close cancel/discard a vanilla inline chat session fixes https://github.com/microsoft/vscode/issues/208585 * show inline chat content widget below the selection https://github.com/microsoft/vscode/issues/208597
This commit is contained in:
parent
32690e164d
commit
b37d8bc51f
|
@ -454,10 +454,6 @@ export class AcceptChanges extends AbstractInlineChatAction {
|
||||||
keybinding: [{
|
keybinding: [{
|
||||||
weight: KeybindingWeight.WorkbenchContrib + 10,
|
weight: KeybindingWeight.WorkbenchContrib + 10,
|
||||||
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
primary: KeyMod.CtrlCmd | KeyCode.Enter,
|
||||||
}, {
|
|
||||||
primary: KeyCode.Escape,
|
|
||||||
weight: KeybindingWeight.WorkbenchContrib,
|
|
||||||
when: CTX_INLINE_CHAT_USER_DID_EDIT
|
|
||||||
}],
|
}],
|
||||||
menu: {
|
menu: {
|
||||||
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages)),
|
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages)),
|
||||||
|
@ -480,7 +476,7 @@ export class CancelSessionAction extends AbstractInlineChatAction {
|
||||||
id: 'inlineChat.cancel',
|
id: 'inlineChat.cancel',
|
||||||
title: localize('cancel', 'Cancel'),
|
title: localize('cancel', 'Cancel'),
|
||||||
icon: Codicon.clearAll,
|
icon: Codicon.clearAll,
|
||||||
precondition: CTX_INLINE_CHAT_VISIBLE,
|
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EDIT_MODE.isEqualTo(EditMode.Preview)),
|
||||||
keybinding: {
|
keybinding: {
|
||||||
weight: KeybindingWeight.EditorContrib - 1,
|
weight: KeybindingWeight.EditorContrib - 1,
|
||||||
primary: KeyCode.Escape
|
primary: KeyCode.Escape
|
||||||
|
@ -510,7 +506,8 @@ export class CloseAction extends AbstractInlineChatAction {
|
||||||
precondition: CTX_INLINE_CHAT_VISIBLE,
|
precondition: CTX_INLINE_CHAT_VISIBLE,
|
||||||
keybinding: {
|
keybinding: {
|
||||||
weight: KeybindingWeight.EditorContrib - 1,
|
weight: KeybindingWeight.EditorContrib - 1,
|
||||||
primary: KeyCode.Escape
|
primary: KeyCode.Escape,
|
||||||
|
when: CTX_INLINE_CHAT_USER_DID_EDIT.negate()
|
||||||
},
|
},
|
||||||
menu: {
|
menu: {
|
||||||
id: MENU_INLINE_CHAT_WIDGET,
|
id: MENU_INLINE_CHAT_WIDGET,
|
||||||
|
@ -521,7 +518,7 @@ export class CloseAction extends AbstractInlineChatAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
|
async runInlineChatCommand(_accessor: ServicesAccessor, ctrl: InlineChatController, _editor: ICodeEditor, ..._args: any[]): Promise<void> {
|
||||||
ctrl.finishExistingSession();
|
ctrl.cancelSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ export class InlineChatContentWidget implements IContentWidget {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
position: this._position,
|
position: this._position,
|
||||||
preference: [ContentWidgetPositionPreference.ABOVE, ContentWidgetPositionPreference.BELOW]
|
preference: [ContentWidgetPositionPreference.BELOW]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -934,7 +934,13 @@ export class InlineChatController implements IEditorContribution {
|
||||||
this._zone.value.updatePositionAndHeight(widgetPosition);
|
this._zone.value.updatePositionAndHeight(widgetPosition);
|
||||||
|
|
||||||
} else if (initialRender) {
|
} else if (initialRender) {
|
||||||
widgetPosition = this._editor.getSelection().getStartPosition();
|
const selection = this._editor.getSelection();
|
||||||
|
widgetPosition = selection.getEndPosition();
|
||||||
|
if (Range.spansMultipleLines(selection) && widgetPosition.column === 1) {
|
||||||
|
// selection ends on "nothing" -> move up to match the
|
||||||
|
// rendered/visible part of the selection
|
||||||
|
widgetPosition = this._editor.getModel().validatePosition(widgetPosition.delta(-1, Number.MAX_SAFE_INTEGER));
|
||||||
|
}
|
||||||
this._input.value.show(widgetPosition);
|
this._input.value.show(widgetPosition);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue