Skip to content

Commit

Permalink
add delete as default keybinding for removing file from working set…
Browse files Browse the repository at this point in the history
…, ctx key (#237513)

* fix #10338

* add ctx key for working set, use it for the when clause
  • Loading branch information
meganrogge authored Jan 9, 2025
1 parent a26fe3e commit 4dd6e8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ registerAction2(class RemoveFileFromWorkingSet extends WorkingSetAction {
order: 5,
group: 'navigation'
}],
keybinding: {
primary: KeyCode.Delete,
when: ContextKeyExpr.and(ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession), ChatContextKeys.inChatEditWorkingSet),
weight: KeybindingWeight.WorkbenchContrib,
}
});
}

Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
readonly onDidAcceptFollowup = this._onDidAcceptFollowup.event;

private readonly _attachmentModel: ChatAttachmentModel;
private _inChatEditWorkingSetCtx: IContextKey<boolean> | undefined;

public get attachmentModel(): ChatAttachmentModel {
return this._attachmentModel;
}
Expand Down Expand Up @@ -643,6 +645,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
ChatContextKeys.inChatInput.bindTo(inputScopedContextKeyService).set(true);
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, inputScopedContextKeyService])));

this._inChatEditWorkingSetCtx = ChatContextKeys.inChatEditWorkingSet.bindTo(this.contextKeyService);

const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(inputScopedContextKeyService, this));
this.historyNavigationBackwardsEnablement = historyNavigationBackwardsEnablement;
this.historyNavigationForewardsEnablement = historyNavigationForwardsEnablement;
Expand Down Expand Up @@ -1268,6 +1272,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge

// Working set
const workingSetContainer = innerContainer.querySelector('.chat-editing-session-list') as HTMLElement ?? dom.append(innerContainer, $('.chat-editing-session-list'));
this._register(addDisposableListener(workingSetContainer, 'focusin', () => this._inChatEditWorkingSetCtx?.set(true)));
this._register(addDisposableListener(workingSetContainer, 'focusout', () => this._inChatEditWorkingSetCtx?.set(false)));
if (!this._chatEditList) {
this._chatEditList = this._chatEditsListPool.get();
const list = this._chatEditList.object;
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/chat/common/chatContextKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export namespace ChatContextKeys {
export const inputHasFocus = new RawContextKey<boolean>('chatInputHasFocus', false, { type: 'boolean', description: localize('interactiveInputHasFocus', "True when the chat input has focus.") });
export const inChatInput = new RawContextKey<boolean>('inChatInput', false, { type: 'boolean', description: localize('inInteractiveInput', "True when focus is in the chat input, false otherwise.") });
export const inChatSession = new RawContextKey<boolean>('inChat', false, { type: 'boolean', description: localize('inChat', "True when focus is in the chat widget, false otherwise.") });
export const inChatEditWorkingSet = new RawContextKey<boolean>('inChatEditWorkingSet', false, { type: 'boolean', description: localize('inChatEditWorkingSet', "True when focus is in the chat edit working set, false otherwise.") });

export const supported = ContextKeyExpr.or(IsWebContext.toNegated(), RemoteNameContext.notEqualsTo('')); // supported on desktop and in web only with a remote connection
export const enabled = new RawContextKey<boolean>('chatIsEnabled', false, { type: 'boolean', description: localize('chatIsEnabled', "True when chat is enabled because a default chat participant is activated with an implementation.") });
Expand Down

0 comments on commit 4dd6e8e

Please sign in to comment.