Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/providers/OilFileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export class OilFileSystemProvider implements vscode.FileSystemProvider {
>();
readonly onDidChangeFile = this._onDidChangeFile.event;

private _documents = new Map<string, Uint8Array>();

// Create or update an in-memory document
writeFile(_uri: vscode.Uri, _content: Uint8Array): void {}

Expand All @@ -24,25 +22,18 @@ export class OilFileSystemProvider implements vscode.FileSystemProvider {
const newOilState = initOilState();
setOilState(newOilState);
oilState = newOilState;
this._documents.clear(); // Clear cache on new state
}
const content = this._documents.get(uri.toString());
if (content) {
return content;
}
const folderPath = oilUriToDiskPath(uri);
const directoryContent = await getDirectoryListing(folderPath, oilState);
if (!directoryContent) {
throw vscode.FileSystemError.FileNotFound(uri);
}
const buffer = Buffer.from(directoryContent);
this._documents.set(uri.toString(), buffer);
return buffer;
}

// Delete an in-memory document
delete(uri: vscode.Uri): void {
this._documents.delete(uri.toString());
this._onDidChangeFile.fire([{ type: vscode.FileChangeType.Changed, uri }]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ suite("oil.code", () => {
assert.ok(previewEditor, "No editor found for the preview tab");
assert.strictEqual(
previewEditor.document.getText(),
["/000 ../", "/000 oil-file1.md", "/000 oil-file2.md"].join(newline),
["/000 ../", "/002 oil-file1.md", "/003 oil-file2.md"].join(newline),
"Preview content does not match expected content"
);
});
Expand Down Expand Up @@ -735,7 +735,7 @@ suite("oil.code", () => {
assert.ok(previewEditor, "No editor found for the preview tab");
assert.strictEqual(
previewEditor.document.getText(),
["/000 ../", "/000 oil-dir/"].join(newline),
["/000 ../", "/001 oil-dir/"].join(newline),
"Preview content does not match expected content"
);
});
Expand Down
12 changes: 5 additions & 7 deletions src/utils/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function getDirectoryListing(
if (oilState.visitedPaths.has(folderPathUri)) {
const previousListings = oilState.visitedPaths.get(folderPathUri)!;
for (const file of previousListings) {
const fileName = file.slice(4);
const fileName = file.slice(5);
if (listings.includes(fileName)) {
existingFiles.set(fileName, file);
}
Expand All @@ -68,13 +68,11 @@ export async function getDirectoryListing(
}

// Use and increment the global counter for each file/directory
const identifier = preview
? GO_UP_IDENTIFIER
: `/${oilState.identifierCounter.toString().padStart(3, "0")}`;
const identifier = `/${oilState.identifierCounter
.toString()
.padStart(3, "0")}`;

if (!preview) {
oilState.identifierCounter++;
}
oilState.identifierCounter++;

return `${identifier} ${name}`;
});
Expand Down
Loading