Skip to content

Commit a1e5611

Browse files
committed
Update file system watchers and logic to correctly handle .cursorignore and .codeiumignore files alongside .gitignore
1 parent 072b481 commit a1e5611

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export class WorkspaceProvider
5555
this.watcher.onDidChange((uri) => this._on_file_system_changed(uri.fsPath))
5656
this.watcher.onDidDelete((uri) => this._on_file_system_changed(uri.fsPath))
5757

58-
this.gitignore_watcher =
59-
vscode.workspace.createFileSystemWatcher('**/.gitignore')
58+
this.gitignore_watcher = vscode.workspace.createFileSystemWatcher(
59+
'**/{.gitignore,.cursorignore,.codeiumignore}'
60+
)
6061
this.gitignore_watcher.onDidCreate(() => this._load_all_gitignore_files())
6162
this.gitignore_watcher.onDidChange(() => this._load_all_gitignore_files())
6263
this.gitignore_watcher.onDidDelete(() => this._load_all_gitignore_files())
@@ -284,7 +285,13 @@ export class WorkspaceProvider
284285
const workspace_root = this.get_workspace_root_for_file(changed_file_path)
285286
if (!workspace_root) return
286287

287-
if (path.basename(changed_file_path) == '.gitignore') return
288+
if (
289+
['.gitignore', '.cursorignore', '.codeiumignore'].includes(
290+
path.basename(changed_file_path)
291+
)
292+
) {
293+
return
294+
}
288295

289296
this.file_token_counts.delete(changed_file_path)
290297

@@ -318,7 +325,13 @@ export class WorkspaceProvider
318325
const workspace_root = this.get_workspace_root_for_file(created_file_path)
319326
if (!workspace_root) return
320327

321-
if (path.basename(created_file_path) == '.gitignore') return
328+
if (
329+
['.gitignore', '.cursorignore', '.codeiumignore'].includes(
330+
path.basename(created_file_path)
331+
)
332+
) {
333+
return
334+
}
322335

323336
this.file_workspace_map.set(created_file_path, workspace_root)
324337

@@ -1206,7 +1219,9 @@ export class WorkspaceProvider
12061219

12071220
// Load .gitignore from all levels of the workspace
12081221
private async _load_all_gitignore_files(): Promise<void> {
1209-
const gitignore_files = await vscode.workspace.findFiles('**/.gitignore')
1222+
const gitignore_files = await vscode.workspace.findFiles(
1223+
'**/{.gitignore,.cursorignore,.codeiumignore}'
1224+
)
12101225
this.combined_gitignore = ignore() // Reset
12111226

12121227
for (const file_uri of gitignore_files) {
@@ -1237,7 +1252,7 @@ export class WorkspaceProvider
12371252
} catch (error) {
12381253
Logger.error({
12391254
function_name: 'load_all_gitignore_files',
1240-
message: `Error reading .gitignore file at ${gitignore_path}`,
1255+
message: `Error reading ignore file at ${gitignore_path}`,
12411256
data: error
12421257
})
12431258
}

0 commit comments

Comments
 (0)