From 5afff699e1482ec22824113be0482a9b187a3247 Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Fri, 15 Sep 2023 18:51:36 +0900 Subject: [PATCH 1/2] Revert the test case which has been failing due to auto-indent feature --- .../commands/kill-yank/kill-ring-yank.test.ts | 80 +++++++++---------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts b/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts index 44aafee849..f5f5c1cabb 100644 --- a/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts +++ b/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts @@ -515,47 +515,45 @@ ABCDEFGHIJ`, }); }); -// NOTE: This test suite has been commented out due to https://github.com/whitphx/vscode-emacs-mcx/issues/1249 -// TODO: Fix the problem and enable this test suite again. -// suite("yank pop with auto-indent", () => { -// let activeTextEditor: vscode.TextEditor; - -// teardown(cleanUpWorkspace); - -// test("Yank in a language that has auto-indent support", async function () { -// activeTextEditor = await setupWorkspace("", { language: "typescript" }); -// activeTextEditor.options.tabSize = 4; - -// const killRing = new KillRing(60); -// const emulator = new EmacsEmulator(activeTextEditor, killRing); - -// // Kill texts -// await clearTextEditor(activeTextEditor, "foo"); // No indent -// await vscode.commands.executeCommand("editor.action.selectAll"); -// await emulator.runCommand("killRegion"); - -// await clearTextEditor(activeTextEditor, "bar"); // No indent -// await vscode.commands.executeCommand("editor.action.selectAll"); -// await emulator.runCommand("killRegion"); - -// // Initialize with parentheses, that triggers auto-indent to inner text -// const initialText = "{\n\n}"; -// await clearTextEditor(activeTextEditor, initialText); -// setEmptyCursors(activeTextEditor, [1, 0]); - -// // Yank pastes "bar" with auto-indentation -// await emulator.runCommand("yank"); -// assertTextEqual(activeTextEditor, "{\n bar\n}"); - -// // YankPop pastes "foo" with auto-indentation -// await emulator.runCommand("yankPop"); -// assertTextEqual(activeTextEditor, "{\n foo\n}"); - -// // yankPop again -// await emulator.runCommand("yankPop"); -// assertTextEqual(activeTextEditor, "{\n bar\n}"); -// }); -// }); +suite("yank pop with auto-indent", () => { + let activeTextEditor: vscode.TextEditor; + + teardown(cleanUpWorkspace); + + test("Yank in a language that has auto-indent support", async function () { + activeTextEditor = await setupWorkspace("", { language: "typescript" }); + activeTextEditor.options.tabSize = 4; + + const killRing = new KillRing(60); + const emulator = new EmacsEmulator(activeTextEditor, killRing); + + // Kill texts + await clearTextEditor(activeTextEditor, "foo"); // No indent + await vscode.commands.executeCommand("editor.action.selectAll"); + await emulator.runCommand("killRegion"); + + await clearTextEditor(activeTextEditor, "bar"); // No indent + await vscode.commands.executeCommand("editor.action.selectAll"); + await emulator.runCommand("killRegion"); + + // Initialize with parentheses, that triggers auto-indent to inner text + const initialText = "{\n\n}"; + await clearTextEditor(activeTextEditor, initialText); + setEmptyCursors(activeTextEditor, [1, 0]); + + // Yank pastes "bar" with auto-indentation + await emulator.runCommand("yank"); + assertTextEqual(activeTextEditor, "{\n bar\n}"); + + // YankPop pastes "foo" with auto-indentation + await emulator.runCommand("yankPop"); + assertTextEqual(activeTextEditor, "{\n foo\n}"); + + // yankPop again + await emulator.runCommand("yankPop"); + assertTextEqual(activeTextEditor, "{\n bar\n}"); + }); +}); suite("Kill and yank with multi cursor, killing at 2 cursors in different lines", () => { let activeTextEditor: vscode.TextEditor; From 835c6bda72d45d9ec99d3215ea9c9492d02a10ce Mon Sep 17 00:00:00 2001 From: "Yuichiro Tachibana (Tsuchiya)" Date: Fri, 15 Sep 2023 18:59:13 +0900 Subject: [PATCH 2/2] Add delays --- src/test/suite/commands/kill-yank/kill-ring-yank.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts b/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts index f5f5c1cabb..9ed9e750c0 100644 --- a/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts +++ b/src/test/suite/commands/kill-yank/kill-ring-yank.test.ts @@ -9,6 +9,7 @@ import { assertTextEqual, cleanUpWorkspace, clearTextEditor, + delay, setEmptyCursors, setupWorkspace, } from "../../utils"; @@ -543,14 +544,17 @@ suite("yank pop with auto-indent", () => { // Yank pastes "bar" with auto-indentation await emulator.runCommand("yank"); + await delay(10); assertTextEqual(activeTextEditor, "{\n bar\n}"); // YankPop pastes "foo" with auto-indentation await emulator.runCommand("yankPop"); + await delay(10); assertTextEqual(activeTextEditor, "{\n foo\n}"); // yankPop again await emulator.runCommand("yankPop"); + await delay(10); assertTextEqual(activeTextEditor, "{\n bar\n}"); }); });