Skip to content

Commit a346dc0

Browse files
committed
Add expand and collapse folder commands with state management for the Code Web Chat view
1 parent a10afdc commit a346dc0

3 files changed

Lines changed: 68 additions & 5 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@
153153
"category": "Code Web Chat",
154154
"icon": "$(clear-all)"
155155
},
156+
{
157+
"command": "codeWebChat.expandFolders",
158+
"title": "Expand Folders",
159+
"category": "Code Web Chat",
160+
"icon": "$(expand-all)"
161+
},
156162
{
157163
"command": "codeWebChat.collapseFolders",
158164
"title": "Collapse Folders",
@@ -370,6 +376,10 @@
370376
"command": "codeWebChat.checkAllOpenEditors",
371377
"when": "false"
372378
},
379+
{
380+
"command": "codeWebChat.expandFolders",
381+
"when": "false"
382+
},
373383
{
374384
"command": "codeWebChat.collapseFolders",
375385
"when": "false"
@@ -462,6 +472,16 @@
462472
"when": "view == codeWebChatViewContext",
463473
"group": "navigation@2"
464474
},
475+
{
476+
"command": "codeWebChat.expandFolders",
477+
"when": "view == codeWebChatViewContext",
478+
"group": "navigation@3"
479+
},
480+
{
481+
"command": "codeWebChat.collapseFolders",
482+
"when": "view == codeWebChatViewContext",
483+
"group": "navigation@4"
484+
},
465485
{
466486
"command": "codeWebChat.checkAll",
467487
"when": "view == codeWebChatViewWorkspace",

‎apps/editor/src/context/context-initialization.ts‎

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ export const context_initialization = async (
151151
const shared_state = SharedFileState.get_instance()
152152
shared_state.set_providers(workspace_provider, open_editors_provider)
153153

154-
workspace_provider.load_checked_files_state()
155-
156154
context.subscriptions.push({
157155
dispose: () => shared_state.dispose()
158156
})
@@ -177,7 +175,7 @@ export const context_initialization = async (
177175
manageCheckboxStateManually: true
178176
})
179177

180-
const context_view = vscode.window.createTreeView('codeWebChatViewContext', {
178+
let context_view = vscode.window.createTreeView('codeWebChatViewContext', {
181179
treeDataProvider: context_provider,
182180
manageCheckboxStateManually: true
183181
})
@@ -299,8 +297,38 @@ export const context_initialization = async (
299297
)
300298
}
301299
),
300+
vscode.commands.registerCommand('codeWebChat.expandFolders', async () => {
301+
workspace_provider.set_context_view_collapsible_state(
302+
vscode.TreeItemCollapsibleState.Expanded
303+
)
304+
workspace_view.dispose()
305+
context_view.dispose()
306+
await new Promise((resolve) => setTimeout(resolve, 0))
307+
308+
workspace_view = vscode.window.createTreeView(
309+
'codeWebChatViewWorkspace',
310+
{
311+
treeDataProvider: workspace_provider!,
312+
manageCheckboxStateManually: true
313+
}
314+
)
315+
316+
context_view = vscode.window.createTreeView('codeWebChatViewContext', {
317+
treeDataProvider: context_provider,
318+
manageCheckboxStateManually: true
319+
})
320+
321+
register_workspace_view_handlers(workspace_view)
322+
register_workspace_view_handlers(context_view)
323+
context.subscriptions.push(workspace_view)
324+
context.subscriptions.push(context_view)
325+
}),
302326
vscode.commands.registerCommand('codeWebChat.collapseFolders', async () => {
327+
workspace_provider.set_context_view_collapsible_state(
328+
vscode.TreeItemCollapsibleState.Collapsed
329+
)
303330
workspace_view.dispose()
331+
context_view.dispose()
304332
await new Promise((resolve) => setTimeout(resolve, 0))
305333

306334
workspace_view = vscode.window.createTreeView(
@@ -311,8 +339,15 @@ export const context_initialization = async (
311339
}
312340
)
313341

342+
context_view = vscode.window.createTreeView('codeWebChatViewContext', {
343+
treeDataProvider: context_provider,
344+
manageCheckboxStateManually: true
345+
})
346+
314347
register_workspace_view_handlers(workspace_view)
348+
register_workspace_view_handlers(context_view)
315349
context.subscriptions.push(workspace_view)
350+
context.subscriptions.push(context_view)
316351
}),
317352
vscode.commands.registerCommand('codeWebChat.clearChecks', async () => {
318353
await workspace_provider!.clear_checks()

‎apps/editor/src/context/providers/workspace/workspace-provider.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ export class WorkspaceProvider
6666
public gitignore_initialization: Promise<void>
6767
public ranges_initialization: Promise<void>
6868
public use_compact_token_count: boolean = false
69+
private _context_view_collapsible_state: vscode.TreeItemCollapsibleState =
70+
vscode.TreeItemCollapsibleState.Expanded
71+
72+
public set_context_view_collapsible_state(
73+
state: vscode.TreeItemCollapsibleState
74+
) {
75+
this._context_view_collapsible_state = state
76+
}
6977

7078
public set_use_compact_token_count(use_compact: boolean) {
7179
if (this.use_compact_token_count != use_compact) {
@@ -715,7 +723,7 @@ export class WorkspaceProvider
715723
name,
716724
uri,
717725
context_view
718-
? vscode.TreeItemCollapsibleState.Expanded
726+
? this._context_view_collapsible_state
719727
: vscode.TreeItemCollapsibleState.Collapsed,
720728
true,
721729
this._checked_items.get(root) ??
@@ -974,7 +982,7 @@ export class WorkspaceProvider
974982
uri,
975983
is_directory
976984
? context_view
977-
? vscode.TreeItemCollapsibleState.Expanded
985+
? this._context_view_collapsible_state
978986
: vscode.TreeItemCollapsibleState.Collapsed
979987
: vscode.TreeItemCollapsibleState.None,
980988
is_directory,

0 commit comments

Comments
 (0)