Skip to content

Commit be0bfb6

Browse files
committed
Automatically check newly created files if not ignored, then update the check state of their parent directories
1 parent be9af49 commit be0bfb6

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,19 @@ export class WorkspaceProvider
386386

387387
private async _handle_file_create(created_file_path?: string): Promise<void> {
388388
if (created_file_path) {
389-
const parent_dir = path.dirname(created_file_path)
390-
const parent_state = this.checked_items.get(parent_dir)
391-
392-
if (parent_state == vscode.TreeItemCheckboxState.Checked) {
393-
if (!should_ignore_file(created_file_path, this.ignored_extensions)) {
394-
this.checked_items.set(
395-
created_file_path,
396-
vscode.TreeItemCheckboxState.Checked
397-
)
398-
this._on_did_change_checked_files.fire()
389+
if (!should_ignore_file(created_file_path, this.ignored_extensions)) {
390+
this.checked_items.set(
391+
created_file_path,
392+
vscode.TreeItemCheckboxState.Checked
393+
)
394+
let dir_path = path.dirname(created_file_path)
395+
const workspace_root =
396+
this.get_workspace_root_for_file(created_file_path)
397+
while (workspace_root && dir_path.startsWith(workspace_root)) {
398+
await this._update_parent_state(dir_path)
399+
dir_path = path.dirname(dir_path)
399400
}
401+
this._on_did_change_checked_files.fire()
400402
}
401403

402404
this.file_token_counts.delete(created_file_path)

0 commit comments

Comments
 (0)