Skip to content

Commit f85d0a4

Browse files
committed
Migrate file exclusion logic from a static extension blacklist to configurable glob patterns
1 parent 83df398 commit f85d0a4

12 files changed

Lines changed: 106 additions & 344 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<a href="https://marketplace.visualstudio.com/items?itemName=robertpiosik.gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-VS_Code_Marketplace-blue" alt="Get from Visual Studio Code Marketplace" /></a> <a href="https://open-vsx.org/extension/robertpiosik/gemini-coder" target="_blank"><img src="https://img.shields.io/badge/Install-Open_VSX_Registry-a60ee5" alt="Get from Open VSX Registry" /></a> <a href="https://github.com/robertpiosik/CodeWebChat/blob/dev/LICENSE" target="_blank"><img src="https://img.shields.io/badge/License-GPL--3.0-green.svg" alt="License: GPL-3.0" /></a>
44

5-
The unlimited AI coding in free chatbots for VS Code, Cursor and Windsurf.
5+
Unlimited AI coding in free chatbots for VS Code, Cursor and Windsurf.
66

77
CWC is community driven. Join our [discord server](https://discord.gg/KJySXsrSX5) and get involved!
88

‎packages/vscode/package.json‎

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
4-
"description": "The unlimited AI coding in free chatbots (CWC)",
4+
"description": "Unlimited AI coding in free chatbots (CWC)",
55
"version": "1.465.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
@@ -537,15 +537,58 @@
537537
"description": "The instructions used when generating a commit message.",
538538
"default": "Write a brief and precise summary for the changes, limited to a single sentence if possible and nothing else. Use an imperative tone to ensure clarity and focus on the primary change or purpose."
539539
},
540-
"codeWebChat.ignoredExtensions": {
540+
"codeWebChat.ignorePatterns": {
541541
"type": "array",
542-
"description": "List of file extensions to ignore in the context.",
542+
"description": "List of glob patterns to ignore files and folders in the context.",
543543
"default": [
544-
"svg"
544+
"**/*.svg",
545+
"**/package-lock.json",
546+
"**/pnpm-lock.yaml",
547+
"**/*.png",
548+
"**/*.jpg",
549+
"**/*.jpeg",
550+
"**/*.gif",
551+
"**/*.bmp",
552+
"**/*.ico",
553+
"**/*.webp",
554+
"**/*.tiff",
555+
"**/*.psd",
556+
"**/*.avif",
557+
"**/*.mp4",
558+
"**/*.webm",
559+
"**/*.avi",
560+
"**/*.mov",
561+
"**/*.wmv",
562+
"**/*.flv",
563+
"**/*.mkv",
564+
"**/*.mp3",
565+
"**/*.wav",
566+
"**/*.ogg",
567+
"**/*.m4a",
568+
"**/*.aac",
569+
"**/*.flac",
570+
"**/*.zip",
571+
"**/*.rar",
572+
"**/*.7z",
573+
"**/*.tar",
574+
"**/*.gz",
575+
"**/*.bz2",
576+
"**/*.ttf",
577+
"**/*.otf",
578+
"**/*.woff",
579+
"**/*.woff2",
580+
"**/*.eot",
581+
"**/*.pdf",
582+
"**/*.exe",
583+
"**/*.dll",
584+
"**/*.so",
585+
"**/*.dylib",
586+
"**/*.bin",
587+
"**/*.vsidx"
545588
],
546589
"items": {
547590
"type": "string",
548-
"description": "File extension to ignore (without the dot)"
591+
"description": "A glob pattern."
549592
}
550593
},
551594
"codeWebChat.editFormatInstructions": {

‎packages/vscode/src/commands/checkpoints-command/utils/clean-directory.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as vscode from 'vscode'
22
import * as path from 'path'
33
import { WorkspaceProvider } from '../../../context/providers/workspace-provider'
4-
import { should_ignore_file } from '../../../context/utils/should-ignore-file'
54

65
export const clean_directory = async (params: {
76
dir_uri: vscode.Uri
@@ -19,10 +18,7 @@ export const clean_directory = async (params: {
1918

2019
if (
2120
type != vscode.FileType.Directory &&
22-
should_ignore_file(
23-
entry_uri.fsPath,
24-
params.workspace_provider.ignored_extensions
25-
)
21+
params.workspace_provider.is_ignored_by_patterns(entry_uri.fsPath)
2622
) {
2723
continue
2824
}

‎packages/vscode/src/commands/checkpoints-command/utils/copy-optimised-recursively.ts‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs/promises'
44
import { WorkspaceProvider } from '../../../context/providers/workspace-provider'
5-
import { should_ignore_file } from '../../../context/utils/should-ignore-file'
65

76
const directory_contains_ignored = async (
87
dir_uri: vscode.Uri,
@@ -37,12 +36,7 @@ const directory_contains_ignored = async (
3736
return true
3837
}
3938
} else if (entry_stat.type == vscode.FileType.File) {
40-
if (
41-
should_ignore_file(
42-
entry_uri.fsPath,
43-
workspace_provider.ignored_extensions
44-
)
45-
) {
39+
if (workspace_provider.is_ignored_by_patterns(entry_uri.fsPath)) {
4640
return true
4741
}
4842
}
@@ -95,12 +89,7 @@ export const copy_optimised_recursively = async (
9589
)
9690
}
9791
} else if (source_stat.type == vscode.FileType.File) {
98-
if (
99-
should_ignore_file(
100-
source_uri.fsPath,
101-
workspace_provider.ignored_extensions
102-
)
103-
) {
92+
if (workspace_provider.is_ignored_by_patterns(source_uri.fsPath)) {
10493
return
10594
}
10695
await fs.copyFile(source_uri.fsPath, dest_uri.fsPath)

‎packages/vscode/src/commands/checkpoints-command/utils/sync-directory.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as vscode from 'vscode'
22
import * as path from 'path'
33
import * as fs from 'fs/promises'
44
import { WorkspaceProvider } from '../../../context/providers/workspace-provider'
5-
import { should_ignore_file } from '../../../context/utils/should-ignore-file'
65

76
export const sync_directory = async (params: {
87
source_dir: vscode.Uri
@@ -44,10 +43,7 @@ export const sync_directory = async (params: {
4443

4544
if (
4645
dest_stat.type !== vscode.FileType.Directory &&
47-
should_ignore_file(
48-
dest_uri.fsPath,
49-
params.workspace_provider.ignored_extensions
50-
)
46+
params.workspace_provider.is_ignored_by_patterns(dest_uri.fsPath)
5147
) {
5248
continue
5349
}

‎packages/vscode/src/commands/save-context-command.ts‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as vscode from 'vscode'
22
import * as fs from 'fs'
33
import * as path from 'path'
44
import { WorkspaceProvider } from '../context/providers/workspace-provider'
5-
import { should_ignore_file } from '../context/utils/should-ignore-file'
6-
import { ignored_extensions } from '../context/constants/ignored-extensions'
75
import {
86
SAVED_CONTEXTS_STATE_KEY,
97
LAST_CONTEXT_SAVE_LOCATION_STATE_KEY
@@ -29,16 +27,6 @@ function condense_paths(
2927
dir_to_children.get(parent_dir)!.push(rel_path)
3028
}
3129

32-
const config = vscode.workspace.getConfiguration('codeWebChat')
33-
const config_ignored_extensions = config.get<string[]>(
34-
'ignoredExtensions',
35-
[]
36-
)
37-
const all_ignored_extensions = new Set([
38-
...ignored_extensions,
39-
...config_ignored_extensions
40-
])
41-
4230
function are_all_files_selected(
4331
dir_path: string,
4432
condensed_paths_set: Set<string>
@@ -73,10 +61,7 @@ function condense_paths(
7361
continue
7462
}
7563

76-
if (
77-
!fs.lstatSync(abs_entry_path).isDirectory() &&
78-
should_ignore_file(entry, all_ignored_extensions)
79-
) {
64+
if (workspace_provider.is_ignored_by_patterns(abs_entry_path)) {
8065
continue
8166
}
8267

‎packages/vscode/src/context/constants/ignored-extensions.ts‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎packages/vscode/src/context/providers/open-editors-provider.ts‎

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import * as fs from 'fs'
33
import * as path from 'path'
44
import { FileItem } from './workspace-provider'
55
import { SharedFileState } from '../shared-file-state'
6-
import { ignored_extensions } from '../constants/ignored-extensions'
7-
import { should_ignore_file } from '../utils/should-ignore-file'
86
import { WorkspaceProvider } from './workspace-provider'
97
import { display_token_count } from '../../utils/display-token-count'
108

@@ -23,7 +21,6 @@ export class OpenEditorsProvider
2321
private _file_token_counts: Map<string, number> = new Map()
2422
private _tab_change_handler: vscode.Disposable
2523
private _file_change_watcher: vscode.Disposable
26-
private _ignored_extensions: Set<string> = new Set()
2724
private _initialized: boolean = false
2825
private _opened_from_workspace_view: Set<string> = new Set()
2926
private _non_preview_files: Set<string> = new Set()
@@ -42,8 +39,6 @@ export class OpenEditorsProvider
4239
this._shared_state = SharedFileState.get_instance()
4340
this.workspace_provider = workspace_provider
4441

45-
this._load_ignored_extensions()
46-
4742
this._update_preview_tabs_state()
4843

4944
this._tab_change_handler = vscode.window.tabGroups.onDidChangeTabs((e) => {
@@ -63,10 +58,8 @@ export class OpenEditorsProvider
6358

6459
this._config_change_handler = vscode.workspace.onDidChangeConfiguration(
6560
(event) => {
66-
if (event.affectsConfiguration('codeWebChat.ignoredExtensions')) {
67-
const old_ignored_extensions = new Set(this._ignored_extensions)
68-
this._load_ignored_extensions()
69-
this._uncheck_ignored_files(old_ignored_extensions)
61+
if (event.affectsConfiguration('codeWebChat.ignorePatterns')) {
62+
this._uncheck_ignored_files()
7063
this.refresh()
7164
}
7265
}
@@ -97,18 +90,12 @@ export class OpenEditorsProvider
9790
return this._workspace_roots.find((root) => file_path.startsWith(root))
9891
}
9992

100-
private _uncheck_ignored_files(old_ignored_extensions?: Set<string>): void {
93+
private _uncheck_ignored_files(): void {
10194
const checked_files = this.get_checked_files()
10295

103-
const files_to_uncheck = checked_files.filter((file_path) => {
104-
if (old_ignored_extensions) {
105-
return (
106-
!should_ignore_file(file_path, old_ignored_extensions) &&
107-
should_ignore_file(file_path, this._ignored_extensions)
108-
)
109-
}
110-
return should_ignore_file(file_path, this._ignored_extensions)
111-
})
96+
const files_to_uncheck = checked_files.filter((file_path) =>
97+
this.workspace_provider.is_ignored_by_patterns(file_path)
98+
)
11299

113100
for (const file_path of files_to_uncheck) {
114101
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Unchecked)
@@ -119,20 +106,6 @@ export class OpenEditorsProvider
119106
}
120107
}
121108

122-
private _load_ignored_extensions() {
123-
const config = vscode.workspace.getConfiguration('codeWebChat')
124-
const additional_extensions = config
125-
.get<string[]>('ignoredExtensions', [])
126-
.map((ext) => ext.toLowerCase().replace(/^\./, ''))
127-
128-
this._ignored_extensions = new Set([
129-
...ignored_extensions,
130-
...additional_extensions
131-
])
132-
// Clear token cache to force recalculation
133-
this._file_token_counts.clear()
134-
}
135-
136109
private _update_preview_tabs_state(): void {
137110
this._preview_tabs.clear()
138111

@@ -277,7 +250,7 @@ export class OpenEditorsProvider
277250

278251
const file_name = path.basename(file_path)
279252

280-
if (should_ignore_file(file_path, this._ignored_extensions)) {
253+
if (this.workspace_provider.is_ignored_by_patterns(file_path)) {
281254
continue
282255
}
283256

@@ -400,7 +373,7 @@ export class OpenEditorsProvider
400373

401374
if (!this._is_file_in_any_workspace(file_path)) continue
402375

403-
if (should_ignore_file(file_path, this._ignored_extensions)) continue
376+
if (this.workspace_provider.is_ignored_by_patterns(file_path)) continue
404377

405378
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
406379

@@ -437,7 +410,7 @@ export class OpenEditorsProvider
437410
for (const file_path of file_paths) {
438411
if (!fs.existsSync(file_path)) continue
439412

440-
if (should_ignore_file(file_path, this._ignored_extensions)) continue
413+
if (this.workspace_provider.is_ignored_by_patterns(file_path)) continue
441414

442415
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
443416

0 commit comments

Comments
 (0)