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:
Johannes Rieken 2024-03-27 15:26:11 +01:00 committed by GitHub
parent 32690e164d
commit b37d8bc51f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 9 deletions

View file

@ -454,10 +454,6 @@ export class AcceptChanges extends AbstractInlineChatAction {
keybinding: [{
weight: KeybindingWeight.WorkbenchContrib + 10,
primary: KeyMod.CtrlCmd | KeyCode.Enter,
}, {
primary: KeyCode.Escape,
weight: KeybindingWeight.WorkbenchContrib,
when: CTX_INLINE_CHAT_USER_DID_EDIT
}],
menu: {
when: ContextKeyExpr.and(CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages)),
@ -480,7 +476,7 @@ export class CancelSessionAction extends AbstractInlineChatAction {
id: 'inlineChat.cancel',
title: localize('cancel', 'Cancel'),
icon: Codicon.clearAll,
precondition: CTX_INLINE_CHAT_VISIBLE,
precondition: ContextKeyExpr.and(CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EDIT_MODE.isEqualTo(EditMode.Preview)),
keybinding: {
weight: KeybindingWeight.EditorContrib - 1,
primary: KeyCode.Escape
@ -510,7 +506,8 @@ export class CloseAction extends AbstractInlineChatAction {
precondition: CTX_INLINE_CHAT_VISIBLE,
keybinding: {
weight: KeybindingWeight.EditorContrib - 1,
primary: KeyCode.Escape
primary: KeyCode.Escape,
when: CTX_INLINE_CHAT_USER_DID_EDIT.negate()
},
menu: {
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> {
ctrl.finishExistingSession();
ctrl.cancelSession();
}
}

View file

@ -124,7 +124,7 @@ export class InlineChatContentWidget implements IContentWidget {
}
return {
position: this._position,
preference: [ContentWidgetPositionPreference.ABOVE, ContentWidgetPositionPreference.BELOW]
preference: [ContentWidgetPositionPreference.BELOW]
};
}

View file

@ -934,7 +934,13 @@ export class InlineChatController implements IEditorContribution {
this._zone.value.updatePositionAndHeight(widgetPosition);
} 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);
} else {