Skip to content

Commit aadc5ae

Browse files
committed
Skip processing for excluded files in workspace file system event handlers
- In `workspace-provider.ts`, update `_on_file_system_changed` and `_handle_file_create` to return early if the path is excluded by `this.is_excluded` (checking both `relative_path` and `relative_path + '/'` to handle deleted or directory paths) before reloading gitignores, invalidating token caches, updating parent states, or scheduling refreshes. └── apps └── editor └── src └── context ├── context-initialization.ts ├── helpers │ ├── get-all-workspace-files.ts │ └── get-selected-files.ts ├── providers │ ├── open-editors │ │ └── open-editors-provider.ts │ ├── selected-files │ │ └── selected-files-provider.ts │ └── workspace │ ├── modules │ │ ├── index.ts │ │ └── token-calculator.ts │ └── workspace-provider.ts ├── shared-context-state.ts └── utils └── shrink-file ├── index.ts ├── languages │ ├── c-style.ts │ ├── css.ts │ ├── html.ts │ ├── jsx.ts │ ├── python.ts │ ├── ruby.ts │ └── sql.ts ├── shrink-file.spec.ts ├── shrink-file.ts └── test-cases ├── c-style │ ├── input.txt │ └── output.txt ├── css │ ├── input.txt │ └── output.txt ├── html │ ├── input.txt │ └── output.txt ├── jsx │ ├── input.txt │ └── output.txt ├── python │ ├── input.txt │ └── output.txt ├── ruby │ ├── input.txt │ └── output.txt ├── scss │ ├── input.txt │ └── output.txt └── sql ├── input.txt └── output.txt
1 parent a05c6f7 commit aadc5ae

1 file changed

Lines changed: 39 additions & 26 deletions

File tree

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

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,14 @@ export class WorkspaceProvider
422422
return
423423
}
424424

425+
const relative_path = path.relative(workspace_root, changed_file_path)
426+
if (
427+
this.is_excluded(relative_path) ||
428+
this.is_excluded(relative_path + '/')
429+
) {
430+
return
431+
}
432+
425433
this._token_calculator.invalidate_token_counts_for_file(changed_file_path)
426434

427435
if (!fs.existsSync(changed_file_path)) {
@@ -461,9 +469,16 @@ export class WorkspaceProvider
461469
return
462470
}
463471

472+
const relative_path = path.relative(workspace_root, created_file_path)
473+
if (
474+
this.is_excluded(relative_path) ||
475+
this.is_excluded(relative_path + '/')
476+
) {
477+
return
478+
}
479+
464480
this._file_workspace_map.set(created_file_path, workspace_root)
465481
const parent_dir = path.dirname(created_file_path)
466-
const relative_path = path.relative(workspace_root, created_file_path)
467482

468483
let is_directory = false
469484
try {
@@ -474,36 +489,34 @@ export class WorkspaceProvider
474489
await this._load_all_gitignore_files()
475490
}
476491

477-
if (!this.is_excluded(is_directory ? relative_path + '/' : relative_path)) {
478-
this._checked_items.set(
479-
created_file_path,
480-
vscode.TreeItemCheckboxState.Checked
481-
)
482-
this._selected_timestamps.set(
492+
this._checked_items.set(
493+
created_file_path,
494+
vscode.TreeItemCheckboxState.Checked
495+
)
496+
this._selected_timestamps.set(
497+
created_file_path,
498+
Math.floor(Date.now() / 1000)
499+
)
500+
501+
if (is_directory) {
502+
await this._update_directory_checkbox_state(
483503
created_file_path,
484-
Math.floor(Date.now() / 1000)
504+
vscode.TreeItemCheckboxState.Checked,
505+
false
485506
)
507+
}
486508

487-
if (is_directory) {
488-
await this._update_directory_checkbox_state(
489-
created_file_path,
490-
vscode.TreeItemCheckboxState.Checked,
491-
false
492-
)
493-
}
494-
495-
let dir_path = parent_dir
496-
while (dir_path.startsWith(workspace_root)) {
497-
this._token_calculator.invalidate_directory_selected_count(dir_path)
498-
await this._update_parent_state(dir_path)
499-
const next_dir_path = path.dirname(dir_path)
500-
if (next_dir_path == dir_path) break
501-
dir_path = next_dir_path
502-
}
503-
504-
this._dispatch_change_events()
509+
let dir_path = parent_dir
510+
while (dir_path.startsWith(workspace_root)) {
511+
this._token_calculator.invalidate_directory_selected_count(dir_path)
512+
await this._update_parent_state(dir_path)
513+
const next_dir_path = path.dirname(dir_path)
514+
if (next_dir_path == dir_path) break
515+
dir_path = next_dir_path
505516
}
506517

518+
this._dispatch_change_events()
519+
507520
let dir_path2 = parent_dir
508521
while (dir_path2.startsWith(workspace_root)) {
509522
this._token_calculator.invalidate_directory_counts(dir_path2)

0 commit comments

Comments
 (0)