Skip to content

Commit efdfda9

Browse files
committed
Automatically check newly created files and directories if not excluded or ignored, no longer requiring the parent directory to be checked
1 parent eda0f86 commit efdfda9

1 file changed

Lines changed: 24 additions & 33 deletions

File tree

‎packages/vscode/src/context/providers/workspace-provider.ts‎

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -408,43 +408,34 @@ export class WorkspaceProvider
408408
this.file_workspace_map.set(created_file_path, workspace_root)
409409

410410
const parent_dir = path.dirname(created_file_path)
411-
const parent_state = this.checked_items.get(parent_dir)
411+
const relative_path = path.relative(workspace_root, created_file_path)
412412

413-
if (parent_state === vscode.TreeItemCheckboxState.Checked) {
414-
const relative_path = path.relative(workspace_root, created_file_path)
415-
416-
if (
417-
!this.is_excluded(relative_path) &&
418-
!should_ignore_file(created_file_path, this.ignored_extensions)
419-
) {
420-
const is_directory = fs.statSync(created_file_path).isDirectory()
421-
422-
if (is_directory) {
423-
this.checked_items.set(
424-
created_file_path,
425-
vscode.TreeItemCheckboxState.Checked
426-
)
427-
await this._update_directory_check_state(
428-
created_file_path,
429-
vscode.TreeItemCheckboxState.Checked,
430-
false
431-
)
432-
} else {
433-
this.checked_items.set(
434-
created_file_path,
435-
vscode.TreeItemCheckboxState.Checked
436-
)
437-
}
413+
if (
414+
!this.is_excluded(relative_path) &&
415+
!should_ignore_file(created_file_path, this.ignored_extensions)
416+
) {
417+
this.checked_items.set(
418+
created_file_path,
419+
vscode.TreeItemCheckboxState.Checked
420+
)
421+
const is_directory = fs.statSync(created_file_path).isDirectory()
438422

439-
let dir_path = parent_dir
440-
while (dir_path.startsWith(workspace_root)) {
441-
this.directory_selected_token_counts.delete(dir_path)
442-
await this._update_parent_state(dir_path)
443-
dir_path = path.dirname(dir_path)
444-
}
423+
if (is_directory) {
424+
await this._update_directory_check_state(
425+
created_file_path,
426+
vscode.TreeItemCheckboxState.Checked,
427+
false
428+
)
429+
}
445430

446-
this._on_did_change_checked_files.fire()
431+
let dir_path = parent_dir
432+
while (dir_path.startsWith(workspace_root)) {
433+
this.directory_selected_token_counts.delete(dir_path)
434+
await this._update_parent_state(dir_path)
435+
dir_path = path.dirname(dir_path)
447436
}
437+
438+
this._on_did_change_checked_files.fire()
448439
}
449440

450441
let dir_path = parent_dir

0 commit comments

Comments
 (0)