Skip to content

Commit 8eecb16

Browse files
committed
Refactor the "Find Paths in Clipboard" functionality from the applyContext command into its own dedicated command
1 parent b95ef6f commit 8eecb16

11 files changed

Lines changed: 564 additions & 515 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Generate meaningful summaries of changes adhering to your style.
147147
- `Code Web Chat: Apply Context` - Apply a saved context to either replace or merge with the currently checked files.
148148
- `Code Web Chat: Copy Context` - Copy XML-formatted checked files from the Workspace view to the clipboard.
149149
- `Code Web Chat: Copy Context of Open Editors` - Copy XML-formatted checked files from the Open Editors view to the clipboard.
150+
- `Code Web Chat: Find Paths in Clipboard` - Select files based on paths found in the clipboard text.
150151

151152
## Enterprise security
152153

‎packages/vscode/package.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "AI coding without agents (CWC)",
5-
"version": "1.543.0",
5+
"version": "1.544.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",
@@ -145,6 +145,11 @@
145145
"category": "Code Web Chat",
146146
"icon": "$(save)"
147147
},
148+
{
149+
"command": "codeWebChat.findPathsInClipboard",
150+
"title": "Find Paths in Clipboard",
151+
"category": "Code Web Chat"
152+
},
148153
{
149154
"command": "codeWebChat.checkAll",
150155
"title": "Check All",

‎packages/vscode/src/commands/apply-context-command/apply-context-command.ts‎

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
import { SavedContext } from '@/types/context'
88
import { dictionary } from '@shared/constants/dictionary'
99
import {
10-
handle_clipboard_source,
1110
handle_json_file_source,
1211
handle_unstaged_files_source,
1312
handle_workspace_state_source,
@@ -51,12 +50,7 @@ export function apply_context_command(
5150

5251
const main_quick_pick_options: (vscode.QuickPickItem & {
5352
value: 'internal' | 'file' | 'other'
54-
})[] = [
55-
{
56-
label: 'Source',
57-
kind: vscode.QuickPickItemKind.Separator
58-
} as any
59-
]
53+
})[] = []
6054

6155
main_quick_pick_options.push({
6256
label: 'Workspace state',
@@ -84,6 +78,7 @@ export function apply_context_command(
8478
const main_quick_pick = vscode.window.createQuickPick<
8579
vscode.QuickPickItem & { value: 'internal' | 'file' | 'other' }
8680
>()
81+
main_quick_pick.title = 'Select Source'
8782
main_quick_pick.items = final_quick_pick_options
8883
main_quick_pick.placeholder = 'Select option'
8984
if (last_main_selection_value) {
@@ -143,12 +138,9 @@ export function apply_context_command(
143138
show_main_menu = true
144139
}
145140
} else if (main_selection.value == 'other') {
146-
const BACK_LABEL = '$(arrow-left) Back'
147141
const other_quick_pick_options: (vscode.QuickPickItem & {
148142
value?: 'clipboard' | 'unstaged'
149143
})[] = [
150-
{ label: BACK_LABEL },
151-
{ label: '', kind: vscode.QuickPickItemKind.Separator },
152144
{
153145
label: 'Select files based on paths found in the clipboard text',
154146
value: 'clipboard'
@@ -162,35 +154,53 @@ export function apply_context_command(
162154
const other_quick_pick = vscode.window.createQuickPick<
163155
vscode.QuickPickItem & { value?: 'clipboard' | 'unstaged' }
164156
>()
157+
other_quick_pick.title = 'Select Source'
165158
other_quick_pick.items = other_quick_pick_options
166159
other_quick_pick.placeholder = 'Select other option'
160+
other_quick_pick.buttons = [vscode.QuickInputButtons.Back]
167161

168162
const other_selection = await new Promise<
163+
| 'back'
169164
| (vscode.QuickPickItem & { value?: 'clipboard' | 'unstaged' })
170165
| undefined
171166
>((resolve) => {
172167
let is_accepted = false
173-
other_quick_pick.onDidAccept(() => {
174-
is_accepted = true
175-
resolve(other_quick_pick.selectedItems[0])
176-
other_quick_pick.hide()
177-
})
178-
other_quick_pick.onDidHide(() => {
179-
if (!is_accepted) {
180-
resolve(undefined)
181-
}
182-
other_quick_pick.dispose()
183-
})
168+
let did_trigger_back = false
169+
const disposables: vscode.Disposable[] = []
170+
171+
disposables.push(
172+
other_quick_pick.onDidTriggerButton((button) => {
173+
if (button === vscode.QuickInputButtons.Back) {
174+
did_trigger_back = true
175+
other_quick_pick.hide()
176+
resolve('back')
177+
}
178+
}),
179+
other_quick_pick.onDidAccept(() => {
180+
is_accepted = true
181+
resolve(other_quick_pick.selectedItems[0])
182+
other_quick_pick.hide()
183+
}),
184+
other_quick_pick.onDidHide(() => {
185+
if (!is_accepted && !did_trigger_back) {
186+
resolve('back')
187+
}
188+
disposables.forEach((d) => d.dispose())
189+
other_quick_pick.dispose()
190+
})
191+
)
184192
other_quick_pick.show()
185193
})
186194

187-
if (!other_selection || other_selection.label === BACK_LABEL) {
195+
if (!other_selection || other_selection === 'back') {
188196
show_main_menu = true
189197
continue
190198
}
191199

192200
if (other_selection.value == 'clipboard') {
193-
await handle_clipboard_source(workspace_provider)
201+
await vscode.commands.executeCommand(
202+
'codeWebChat.findPathsInClipboard'
203+
)
194204
return
195205
}
196206
if (other_selection.value == 'unstaged') {

‎packages/vscode/src/commands/apply-context-command/sources/clipboard-source.ts‎

Lines changed: 0 additions & 140 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from './clipboard-source'
21
export * from './json-file-source'
32
export * from './unstaged-files-source'
43
export * from './workspace-state-source'

0 commit comments

Comments
 (0)