Skip to content

Commit 9c77d46

Browse files
committed
Remove quick save slots functionality from the apply context command
1 parent 1e1f0cd commit 9c77d46

6 files changed

Lines changed: 31 additions & 142 deletions

File tree

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

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import * as vscode from 'vscode'
22
import * as fs from 'fs'
33
import * as path from 'path'
44
import { WorkspaceProvider } from '../../context/providers/workspace/workspace-provider'
5-
import {
6-
LAST_APPLY_CONTEXT_OPTION_STATE_KEY,
7-
QUICK_SAVES_STATE_KEY
8-
} from '../../constants/state-keys'
9-
import { SavedContext } from '@/types/context'
5+
import { LAST_APPLY_CONTEXT_OPTION_STATE_KEY } from '../../constants/state-keys'
106
import { dictionary } from '@shared/constants/dictionary'
117
import {
128
handle_unstaged_files_source,
@@ -20,7 +16,6 @@ import {
2016
get_contexts_file_path,
2117
load_and_merge_global_contexts
2218
} from './helpers/saving'
23-
import { handle_quick_save } from './helpers/saving/handle-quick-save'
2419

2520
export const apply_context_command = (
2621
workspace_provider: WorkspaceProvider | undefined,
@@ -86,29 +81,6 @@ export const apply_context_command = (
8681
value: 'other'
8782
})
8883

89-
main_quick_pick_options.push({
90-
label: 'quick saves',
91-
kind: vscode.QuickPickItemKind.Separator,
92-
value: 'separator'
93-
} as any)
94-
95-
const quick_saves = extension_context.workspaceState.get<
96-
Record<number, SavedContext>
97-
>(QUICK_SAVES_STATE_KEY, {})
98-
for (let i = 1; i <= 3; i++) {
99-
const is_saved = !!quick_saves[i]
100-
main_quick_pick_options.push({
101-
label: `Quick save slot ${i}`,
102-
description: is_saved
103-
? `${quick_saves[i].paths.length} paths`
104-
: 'empty',
105-
value: `quick_save_${i}`,
106-
buttons: is_saved
107-
? [{ iconPath: new vscode.ThemeIcon('trash'), tooltip: 'Clear' }]
108-
: []
109-
})
110-
}
111-
11284
const main_quick_pick = vscode.window.createQuickPick<
11385
vscode.QuickPickItem & {
11486
value: 'internal' | 'file' | 'other' | string
@@ -189,20 +161,6 @@ export const apply_context_command = (
189161
}
190162
}
191163
}),
192-
main_quick_pick.onDidTriggerItemButton(async (e) => {
193-
if (e.item.value.startsWith('quick_save_')) {
194-
const slot = parseInt(e.item.value.split('_')[2])
195-
const current = extension_context.workspaceState.get<
196-
Record<number, SavedContext>
197-
>(QUICK_SAVES_STATE_KEY, {})
198-
delete current[slot]
199-
await extension_context.workspaceState.update(
200-
QUICK_SAVES_STATE_KEY,
201-
current
202-
)
203-
resolve({ ...e.item, triggeredButton: e.button })
204-
}
205-
}),
206164
main_quick_pick.onDidAccept(() => {
207165
is_accepted = true
208166
resolve(main_quick_pick.selectedItems[0])
@@ -362,14 +320,6 @@ export const apply_context_command = (
362320
return
363321
}
364322
}
365-
} else if (main_selection.value.startsWith('quick_save_')) {
366-
const slot = parseInt(main_selection.value.split('_')[2])
367-
await handle_quick_save(
368-
slot,
369-
workspace_provider,
370-
extension_context,
371-
on_context_selected
372-
)
373323
}
374324
}
375325
}

‎packages/vscode/src/commands/apply-context-command/helpers/saving/handle-quick-save.ts‎

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './ask-for-new-context-name'
22
export * from './context-file-utils'
33
export * from './path-utils'
4-
export * from './handle-quick-save'
54
export * from './global-storage-utils'

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,20 @@ export const handle_json_file_source = async (
257257
let contexts = load_contexts_from_file(p)
258258
contexts = contexts.filter((c) => c.name !== context_name)
259259

260-
if (files.length > 0) {
261-
const condensed_paths = condense_paths(
262-
files,
263-
root,
264-
workspace_provider
265-
)
266-
const relative_paths = condensed_paths.map((p) =>
267-
p.replace(/\\/g, '/')
268-
)
260+
if (files.length > 0 || current_roots.includes(root)) {
261+
let relative_paths: string[] = []
262+
263+
if (files.length > 0) {
264+
const condensed_paths = condense_paths(
265+
files,
266+
root,
267+
workspace_provider
268+
)
269+
relative_paths = condensed_paths.map((p) =>
270+
p.replace(/\\/g, '/')
271+
)
272+
}
273+
269274
contexts.unshift({
270275
name: context_name,
271276
paths: relative_paths

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,20 @@ export const handle_workspace_state_source = async (
242242
)
243243

244244
const files = files_by_workspace.get(root)
245-
if (files && files.length > 0) {
246-
const condensed_paths = condense_paths(
247-
files,
248-
root,
249-
workspace_provider
250-
)
251-
const relative_paths = condensed_paths.map((p) =>
252-
p.replace(/\\/g, '/')
253-
)
245+
if ((files && files.length > 0) || current_roots.includes(root)) {
246+
let relative_paths: string[] = []
247+
248+
if (files && files.length > 0) {
249+
const condensed_paths = condense_paths(
250+
files,
251+
root,
252+
workspace_provider
253+
)
254+
relative_paths = condensed_paths.map((p) =>
255+
p.replace(/\\/g, '/')
256+
)
257+
}
258+
254259
root_contexts.unshift({
255260
name: context.name,
256261
paths: relative_paths

‎packages/vscode/src/commands/keyword-search-in-folder.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ export const keyword_search_in_folder_command = (
2121

2222
try {
2323
const input_box = vscode.window.createInputBox()
24-
input_box.title = `Keyword Search in ${path.basename(folder_path)}`
24+
input_box.title = 'Keyword Search'
2525
input_box.prompt = 'Enter keywords separated by comma'
2626
input_box.placeholder = 'e.g. user, login, auth'
27-
input_box.ignoreFocusOut = true
2827

2928
const keywords_input = await new Promise<string | undefined>(
3029
(resolve) => {
@@ -34,7 +33,7 @@ export const keyword_search_in_folder_command = (
3433
disposables.push(
3534
input_box.onDidAccept(() => {
3635
const value = input_box.value.trim()
37-
if (value.length === 0) {
36+
if (value.length == 0) {
3837
input_box.validationMessage =
3938
'Please enter at least one keyword'
4039
return

0 commit comments

Comments
 (0)