Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add delete as default keybinding for removing file from working set, ctx key #237513

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading