Skip to content

Commit 68d2d37

Browse files
committed
Refactor .gitignore file handling to use Uri.joinPath for improved path management
1 parent 74dc6c1 commit 68d2d37

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/foam-vscode/src/services/editor.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,10 @@ export async function createMatcherAndDataStore(excludes: string[]): Promise<{
205205

206206
// Read .gitignore files and add patterns to excludePatterns
207207
for (const folder of workspace.workspaceFolders) {
208-
const gitignorePath = path.join(folder.uri.fsPath, '.gitignore');
208+
const gitignoreUri = Uri.joinPath(folder.uri, '.gitignore');
209209
try {
210-
await workspace.fs.stat(Uri.file(gitignorePath)); // Check if the file exists
211-
const gitignoreContent = await workspace.fs.readFile(
212-
Uri.file(gitignorePath)
213-
); // Read the file content
210+
await workspace.fs.stat(gitignoreUri); // Check if the file exists
211+
const gitignoreContent = await workspace.fs.readFile(gitignoreUri); // Read the file content
214212
const patterns = map(
215213
filter(
216214
split(Buffer.from(gitignoreContent).toString('utf-8'), '\n'),
@@ -220,7 +218,7 @@ export async function createMatcherAndDataStore(excludes: string[]): Promise<{
220218
);
221219
excludePatterns.get(folder.name).push(...compact(patterns));
222220

223-
Logger.info(`Excluded patterns from ${gitignorePath}: ${patterns}`);
221+
Logger.info(`Excluded patterns from ${gitignoreUri.path}: ${patterns}`);
224222
} catch (error) {
225223
// .gitignore file does not exist, continue
226224
Logger.error(`Error reading .gitignore file: ${error}`);

0 commit comments

Comments
 (0)