Skip to content

Commit 8f79955

Browse files
committed
Add early exit checks for ignored files in workspace file change handlers
1 parent 67b9973 commit 8f79955

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,11 @@ export class WorkspaceProvider
465465
const workspace_root = this.get_workspace_root_for_file(changed_file_path)
466466
if (!workspace_root) return
467467

468+
// Early exit if the file is ignored/excluded to avoid unnecessary processing
469+
if (this.is_ignored_by_patterns(changed_file_path)) {
470+
return
471+
}
472+
468473
if (
469474
['.gitignore', '.cursorignore', '.codeiumignore'].includes(
470475
path.basename(changed_file_path)
@@ -499,25 +504,23 @@ export class WorkspaceProvider
499504
const workspace_root = this.get_workspace_root_for_file(created_file_path)
500505
if (!workspace_root) return
501506

502-
if (
503-
['.gitignore', '.cursorignore', '.codeiumignore'].includes(
504-
path.basename(created_file_path)
505-
)
506-
) {
507+
const basename = path.basename(created_file_path)
508+
if (['.gitignore', '.cursorignore', '.codeiumignore'].includes(basename)) {
507509
return
508510
}
509511

510-
this._file_workspace_map.set(created_file_path, workspace_root)
512+
if (this.is_ignored_by_patterns(created_file_path)) {
513+
return
514+
}
511515

516+
this._file_workspace_map.set(created_file_path, workspace_root)
512517
const parent_dir = path.dirname(created_file_path)
513518
const relative_path = path.relative(workspace_root, created_file_path)
514519

515520
let is_directory = false
516521
try {
517522
is_directory = fs.statSync(created_file_path).isDirectory()
518-
} catch {
519-
// Ignore if file was deleted quickly
520-
}
523+
} catch {}
521524

522525
if (is_directory) {
523526
await this._load_all_gitignore_files()
@@ -527,10 +530,7 @@ export class WorkspaceProvider
527530
.getConfiguration('codeWebChat')
528531
.get<boolean>('checkNewFiles')
529532

530-
if (
531-
!this.is_excluded(is_directory ? relative_path + '/' : relative_path) &&
532-
!this.is_ignored_by_patterns(created_file_path)
533-
) {
533+
if (!this.is_excluded(is_directory ? relative_path + '/' : relative_path)) {
534534
if (check_new_files) {
535535
this._checked_items.set(
536536
created_file_path,

0 commit comments

Comments
 (0)