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
11 changes: 10 additions & 1 deletion src/commands/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ function closeOldDocument(oldUri: vscode.Uri) {
tab.input.uri.toString() === oldUri.toString()
);
if (oldTab) {
await vscode.window.tabGroups.close(oldTab);
if (oldTab.isDirty) {
// Use the revert and close command to avoid save prompts for dirty tabs
await vscode.window.showTextDocument(oldUri);
await vscode.commands.executeCommand(
"workbench.action.revertAndCloseActiveEditor"
);
} else {
// For clean tabs, just close normally
await vscode.window.tabGroups.close(oldTab);
}
}
} catch (error) {
// Fallback method if tab API fails
Expand Down
7 changes: 4 additions & 3 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,19 @@ suite("oil.code", () => {
editor.selection = new vscode.Selection(position3, position3);

await vscode.commands.executeCommand("oil-code.select");
await sleep(200);
await sleep(300);

const editor3 = vscode.window.activeTextEditor;
assert.ok(editor3, "No active editor3");
editor3.edit((editBuilder) => {
editBuilder.insert(new vscode.Position(0, 8), newline);
editBuilder.insert(new vscode.Position(1, 0), `/002 oil-file.md`);
});
await waitForDocumentText(["/000 ../", "/002 oil-file.md"]);

await saveFile();

await sleep(100);
await sleep(200);

await waitForDocumentText(["/000 ../", "/003 oil-file.md"]);

Expand Down Expand Up @@ -477,7 +478,7 @@ suite("oil.code", () => {
await sleep(100);
editor.selection = new vscode.Selection(1, 5, 1, 5);
await vscode.commands.executeCommand("oil-code.select");
await sleep(300);
await sleep(500);

const editor2 = vscode.window.activeTextEditor;
assert.ok(editor2, "No active editor");
Expand Down
3 changes: 1 addition & 2 deletions src/test/utils/waitFor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as assert from "assert";
import { tryCatch } from "../../tryCatch";
import { error } from "console";

export async function waitFor(
assertion: () => void,
Expand All @@ -12,7 +11,7 @@ export async function waitFor(
}
): Promise<void> {
const startTime = Date.now();
const timeout = options?.timeout || 3000;
const timeout = options?.timeout || 4000;
const interval = options?.interval || 100;
const endTime = startTime + timeout;
while (true) {
Expand Down
Loading