Skip to content

Commit 975a710

Browse files
committed
Rename Context provider and view to Selected Files for improved naming clarity
- rename 'context' pane to 'selected files', rename files as needed
1 parent 22f74f1 commit 975a710

4 files changed

Lines changed: 77 additions & 60 deletions

File tree

‎apps/editor/package.json‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
"initialSize": 1
6969
},
7070
{
71-
"id": "codeWebChatViewContext",
72-
"name": "Context",
71+
"id": "codeWebChatViewSelectedFiles",
72+
"name": "Selected Files",
7373
"icon": "resources/activity-bar-icon.svg",
7474
"visibility": "collapsed",
7575
"initialSize": 1
@@ -549,22 +549,22 @@
549549
"view/title": [
550550
{
551551
"command": "codeWebChat.undoContextSelection",
552-
"when": "view == codeWebChatViewContext",
552+
"when": "view == codeWebChatViewSelectedFiles",
553553
"group": "navigation@1"
554554
},
555555
{
556556
"command": "codeWebChat.redoContextSelection",
557-
"when": "view == codeWebChatViewContext",
557+
"when": "view == codeWebChatViewSelectedFiles",
558558
"group": "navigation@2"
559559
},
560560
{
561561
"command": "codeWebChat.expandContextFolders",
562-
"when": "view == codeWebChatViewContext",
562+
"when": "view == codeWebChatViewSelectedFiles",
563563
"group": "navigation@3"
564564
},
565565
{
566566
"command": "codeWebChat.collapseContextFolders",
567-
"when": "view == codeWebChatViewContext",
567+
"when": "view == codeWebChatViewSelectedFiles",
568568
"group": "navigation@4"
569569
},
570570
{
@@ -740,47 +740,47 @@
740740
},
741741
{
742742
"command": "codeWebChat.referenceInPrompt",
743-
"when": "view == codeWebChatViewWorkspace || view == codeWebChatViewContext",
743+
"when": "view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles",
744744
"group": "1_modification@3"
745745
},
746746
{
747747
"command": "codeWebChat.selectImportedFiles",
748-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
748+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == file || viewItem == contextFile || viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
749749
"group": "1_modification@4"
750750
},
751751
{
752752
"command": "codeWebChat.selectReferencingFiles",
753-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
753+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == contextDirectory || viewItem == workspaceRoot || viewItem == contextWorkspaceRoot)",
754754
"group": "1_modification@5"
755755
},
756756
{
757757
"command": "codeWebChat.searchFilesFromDirectory",
758-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
758+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
759759
"group": "1_modification@6"
760760
},
761761
{
762762
"command": "codeWebChat.setRanges",
763-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && viewItem == file",
763+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && viewItem == file",
764764
"group": "1_modification@7"
765765
},
766766
{
767767
"command": "codeWebChat.findInFolder",
768-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
768+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == directory || viewItem == workspaceRoot || viewItem == contextDirectory || viewItem == contextWorkspaceRoot)",
769769
"group": "2_external@1"
770770
},
771771
{
772772
"command": "codeWebChat.revealInExplorer",
773-
"when": "view == codeWebChatViewWorkspace || view == codeWebChatViewContext",
773+
"when": "view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles",
774774
"group": "2_external@2"
775775
},
776776
{
777777
"command": "codeWebChat.openInIntegratedTerminal",
778-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == workspaceRoot || viewItem == directory || viewItem == contextWorkspaceRoot || viewItem == contextDirectory)",
778+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == workspaceRoot || viewItem == directory || viewItem == contextWorkspaceRoot || viewItem == contextDirectory)",
779779
"group": "2_external@3"
780780
},
781781
{
782782
"command": "codeWebChat.removeFolderFromWorkspace",
783-
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewContext) && (viewItem == workspaceRoot || viewItem == contextWorkspaceRoot) && workspaceFolderCount > 1",
783+
"when": "(view == codeWebChatViewWorkspace || view == codeWebChatViewSelectedFiles) && (viewItem == workspaceRoot || viewItem == contextWorkspaceRoot) && workspaceFolderCount > 1",
784784
"group": "2_external@4"
785785
}
786786
]

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

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
RANGES_STATE_KEY,
1717
type DuplicateWorkspaceContext
1818
} from '../constants/state-keys'
19-
import { ContextProvider } from './providers/context/context-provider'
19+
import { SelectedFilesProvider } from './providers/selected-files/selected-files-provider'
2020
import { is_binary_file } from '../utils/is-binary'
2121

2222
export const token_count_emitter = new EventEmitter()
@@ -117,8 +117,8 @@ export const context_initialization = async (
117117
workspace_folders,
118118
context
119119
})
120-
const context_provider = new ContextProvider(workspace_provider)
121-
context.subscriptions.push(context_provider)
120+
const selected_files_provider = new SelectedFilesProvider(workspace_provider)
121+
context.subscriptions.push(selected_files_provider)
122122

123123
const open_editors_provider = new OpenEditorsProvider({
124124
workspace_folders,
@@ -133,7 +133,7 @@ export const context_initialization = async (
133133

134134
const update_view_badges = async () => {
135135
let context_token_count = 0
136-
if (context_provider && context_view) {
136+
if (selected_files_provider && selected_files_view) {
137137
if (!workspace_provider.is_no_context_mode) {
138138
const token_counts =
139139
await workspace_provider.get_checked_files_token_count()
@@ -149,7 +149,7 @@ export const context_initialization = async (
149149
? `About ${context_token_count} tokens in context`
150150
: ''
151151
}
152-
context_view.badge = undefined
152+
selected_files_view.badge = undefined
153153
}
154154
token_count_emitter.emit('token-count-updated', context_token_count)
155155
}
@@ -180,13 +180,16 @@ export const context_initialization = async (
180180
manageCheckboxStateManually: true
181181
})
182182

183-
let context_view = vscode.window.createTreeView('codeWebChatViewContext', {
184-
treeDataProvider: context_provider,
185-
manageCheckboxStateManually: true
186-
})
183+
let selected_files_view = vscode.window.createTreeView(
184+
'codeWebChatViewSelectedFiles',
185+
{
186+
treeDataProvider: selected_files_provider,
187+
manageCheckboxStateManually: true
188+
}
189+
)
187190

188191
register_workspace_view_handlers(workspace_view)
189-
register_workspace_view_handlers(context_view)
192+
register_workspace_view_handlers(selected_files_view)
190193

191194
const open_editors_view = vscode.window.createTreeView(
192195
'codeWebChatViewOpenEditors',
@@ -200,7 +203,7 @@ export const context_initialization = async (
200203
workspace_provider,
201204
open_editors_provider,
202205
workspace_view,
203-
context_view,
206+
selected_files_view,
204207
open_editors_view
205208
)
206209

@@ -315,37 +318,43 @@ export const context_initialization = async (
315318
vscode.commands.registerCommand(
316319
'codeWebChat.expandContextFolders',
317320
async () => {
318-
workspace_provider.set_context_view_collapsible_state(
321+
workspace_provider.set_selected_files_view_collapsible_state(
319322
vscode.TreeItemCollapsibleState.Expanded
320323
)
321-
context_view.dispose()
324+
selected_files_view.dispose()
322325
await new Promise((resolve) => setTimeout(resolve, 0))
323326

324-
context_view = vscode.window.createTreeView('codeWebChatViewContext', {
325-
treeDataProvider: context_provider,
326-
manageCheckboxStateManually: true
327-
})
327+
selected_files_view = vscode.window.createTreeView(
328+
'codeWebChatViewSelectedFiles',
329+
{
330+
treeDataProvider: selected_files_provider,
331+
manageCheckboxStateManually: true
332+
}
333+
)
328334

329-
register_workspace_view_handlers(context_view)
330-
context.subscriptions.push(context_view)
335+
register_workspace_view_handlers(selected_files_view)
336+
context.subscriptions.push(selected_files_view)
331337
}
332338
),
333339
vscode.commands.registerCommand(
334340
'codeWebChat.collapseContextFolders',
335341
async () => {
336-
workspace_provider.set_context_view_collapsible_state(
342+
workspace_provider.set_selected_files_view_collapsible_state(
337343
vscode.TreeItemCollapsibleState.Collapsed
338344
)
339-
context_view.dispose()
345+
selected_files_view.dispose()
340346
await new Promise((resolve) => setTimeout(resolve, 0))
341347

342-
context_view = vscode.window.createTreeView('codeWebChatViewContext', {
343-
treeDataProvider: context_provider,
344-
manageCheckboxStateManually: true
345-
})
348+
selected_files_view = vscode.window.createTreeView(
349+
'codeWebChatViewSelectedFiles',
350+
{
351+
treeDataProvider: selected_files_provider,
352+
manageCheckboxStateManually: true
353+
}
354+
)
346355

347-
register_workspace_view_handlers(context_view)
348-
context.subscriptions.push(context_view)
356+
register_workspace_view_handlers(selected_files_view)
357+
context.subscriptions.push(selected_files_view)
349358
}
350359
),
351360
vscode.commands.registerCommand(

apps/editor/src/context/providers/context/context-provider.ts renamed to apps/editor/src/context/providers/selected-files/selected-files-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode'
22
import { WorkspaceProvider, FileItem } from '../workspace/workspace-provider'
33

4-
export class ContextProvider implements vscode.TreeDataProvider<FileItem> {
4+
export class SelectedFilesProvider implements vscode.TreeDataProvider<FileItem> {
55
private _onDidChangeTreeData: vscode.EventEmitter<
66
FileItem | undefined | null | void
77
> = new vscode.EventEmitter<FileItem | undefined | null | void>()
@@ -26,7 +26,7 @@ export class ContextProvider implements vscode.TreeDataProvider<FileItem> {
2626
}
2727

2828
getChildren(element?: FileItem): vscode.ProviderResult<FileItem[]> {
29-
return this._workspace_provider.getContextViewChildren(element)
29+
return this._workspace_provider.getSelectedFilesViewChildren(element)
3030
}
3131

3232
dispose() {

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ export class WorkspaceProvider
123123
public gitignore_initialization: Promise<void>
124124
public ranges_initialization: Promise<void>
125125
public use_shrink_token_count: boolean = false
126-
private _context_view_collapsible_state: vscode.TreeItemCollapsibleState =
126+
private _selected_files_view_collapsible_state: vscode.TreeItemCollapsibleState =
127127
vscode.TreeItemCollapsibleState.Expanded
128128
private _workspace_view_collapsible_state: vscode.TreeItemCollapsibleState =
129129
vscode.TreeItemCollapsibleState.Collapsed
130130

131-
public set_context_view_collapsible_state(
131+
public set_selected_files_view_collapsible_state(
132132
state: vscode.TreeItemCollapsibleState
133133
) {
134-
this._context_view_collapsible_state = state
134+
this._selected_files_view_collapsible_state = state
135135
}
136136

137137
public set_workspace_view_collapsible_state(
@@ -697,7 +697,9 @@ export class WorkspaceProvider
697697
: undefined
698698

699699
const formatted_selected =
700-
selected_token_count !== undefined && selected_token_count > 0 && !this._is_no_context_mode
700+
selected_token_count !== undefined &&
701+
selected_token_count > 0 &&
702+
!this._is_no_context_mode
701703
? display_token_count(selected_token_count)
702704
: undefined
703705

@@ -803,7 +805,9 @@ export class WorkspaceProvider
803805
}
804806
}
805807

806-
public async getContextViewChildren(element?: FileItem): Promise<FileItem[]> {
808+
public async getSelectedFilesViewChildren(
809+
element?: FileItem
810+
): Promise<FileItem[]> {
807811
await this.gitignore_initialization
808812
await this.ranges_initialization
809813

@@ -836,7 +840,7 @@ export class WorkspaceProvider
836840
}
837841

838842
private async _get_workspace_folder_items(
839-
context_view = false
843+
is_selected_files_view = false
840844
): Promise<FileItem[]> {
841845
const items: FileItem[] = []
842846
for (let i = 0; i < this._workspace_roots.length; i++) {
@@ -846,7 +850,7 @@ export class WorkspaceProvider
846850
continue
847851
}
848852

849-
if (context_view) {
853+
if (is_selected_files_view) {
850854
const state = this._checked_items.get(root)
851855
const is_partially_checked = this._partially_checked_dirs.has(root)
852856
if (
@@ -869,8 +873,8 @@ export class WorkspaceProvider
869873
new FileItem(
870874
name,
871875
uri,
872-
context_view
873-
? this._context_view_collapsible_state
876+
is_selected_files_view
877+
? this._selected_files_view_collapsible_state
874878
: this._workspace_view_collapsible_state,
875879
true,
876880
this._is_no_context_mode
@@ -887,7 +891,7 @@ export class WorkspaceProvider
887891
true
888892
)
889893
)
890-
if (context_view) {
894+
if (is_selected_files_view) {
891895
const last_item = items[items.length - 1]
892896
last_item.contextValue = 'contextWorkspaceRoot'
893897
}
@@ -1007,7 +1011,7 @@ export class WorkspaceProvider
10071011

10081012
private async _get_files_and_directories(
10091013
dir_path: string,
1010-
context_view = false
1014+
is_selected_files_view = false
10111015
): Promise<FileItem[]> {
10121016
const items: FileItem[] = []
10131017
try {
@@ -1049,7 +1053,7 @@ export class WorkspaceProvider
10491053

10501054
const relative_path = path.relative(workspace_root, full_path)
10511055

1052-
if (context_view) {
1056+
if (is_selected_files_view) {
10531057
const state = this._checked_items.get(full_path)
10541058
const is_partially_checked =
10551059
this._partially_checked_dirs.has(full_path)
@@ -1137,8 +1141,8 @@ export class WorkspaceProvider
11371141
entry.name,
11381142
uri,
11391143
is_directory
1140-
? context_view
1141-
? this._context_view_collapsible_state
1144+
? is_selected_files_view
1145+
? this._selected_files_view_collapsible_state
11421146
: this._workspace_view_collapsible_state
11431147
: vscode.TreeItemCollapsibleState.None,
11441148
is_directory,
@@ -1154,7 +1158,7 @@ export class WorkspaceProvider
11541158
range
11551159
)
11561160

1157-
if (context_view) {
1161+
if (is_selected_files_view) {
11581162
item.contextValue = item.isDirectory
11591163
? 'contextDirectory'
11601164
: 'contextFile'
@@ -1618,7 +1622,11 @@ export class WorkspaceProvider
16181622
this._user_ignore_patterns.add(patterns)
16191623
}
16201624

1621-
this._user_ignore_patterns.add(['node_modules', '.DS_Store', ...IGNORED_LOCK_FILES])
1625+
this._user_ignore_patterns.add([
1626+
'node_modules',
1627+
'.DS_Store',
1628+
...IGNORED_LOCK_FILES
1629+
])
16221630

16231631
const allow_patterns = config.get<string[]>('allowPatterns')
16241632
this._user_allow_patterns = ignore()

0 commit comments

Comments
 (0)