Skip to content

Commit

Permalink
Remove workarounds from src/test/suite/commands/new-line.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx committed Nov 5, 2023
1 parent 38a7b48 commit 560b14a
Showing 1 changed file with 3 additions and 47 deletions.
50 changes: 3 additions & 47 deletions src/test/suite/commands/new-line.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert";
import * as vscode from "vscode";
import { EmacsEmulator } from "../../../emulator";
import { assertTextEqual, cleanUpWorkspace, clearTextEditor, setEmptyCursors, setupWorkspace } from "../utils";
import { assertTextEqual, cleanUpWorkspace, setEmptyCursors, setupWorkspace } from "../utils";

const eols: Array<[vscode.EndOfLine, string]> = [
[vscode.EndOfLine.LF, "\n"],
Expand Down Expand Up @@ -118,33 +118,11 @@ eols.forEach(([eol, eolStr]) => {
assert.strictEqual(activeTextEditor.selection.active.character, 4);
});

const languagesAutoDoc = [
// "c", "cpp" // Auto-indent for doc comments does not work with these languages in test env while I don't know why...
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
];
const languagesAutoDoc = ["c", "cpp", "javascript", "javascriptreact", "typescript", "typescriptreact"];
languagesAutoDoc.forEach((language) => {
test(`newLine does not disable the language specific control in case of ${language}`, async function () {
const initialText = "/** */";

// XXX: First, trigger the language's auto-indent feature without any assertion before the main test execution.
// This is necessary for the test to be successful at VSCode 1.50.
// It may be because the first execution warms up the language server.
// TODO: Remove this workaround with later versions of VSCode
activeTextEditor = await setupWorkspace(initialText, {
eol,
language,
});
emulator = new EmacsEmulator(activeTextEditor);

setEmptyCursors(activeTextEditor, [0, 3]);

await vscode.commands.executeCommand("default:type", { text: "\n" });
await clearTextEditor(activeTextEditor);
// XXX: (end of the workaround)

activeTextEditor = await setupWorkspace(initialText, {
eol,
language,
Expand Down Expand Up @@ -227,33 +205,11 @@ eols.forEach(([eol, eolStr]) => {
assertTextEqual(activeTextEditor, `(${eolStr}${eolStr}${eolStr}${eolStr} ${eolStr})`);
});

const languagesAutoDoc = [
// "c", "cpp" // Auto-indent for doc comments does not work with these languages in test env while I don't know why...
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
];
const languagesAutoDoc = ["c", "cpp", "javascript", "javascriptreact", "typescript", "typescriptreact"];
languagesAutoDoc.forEach((language) => {
test(`newLine does not disable the language specific control in case of ${language}`, async function () {
const initialText = "/** */";

// XXX: First, trigger the language's auto-indent feature without any assertion before the main test execution.
// This is necessary for the test to be successful at VSCode 1.50.
// It may be because the first execution warms up the language server.
// TODO: Remove this workaround with later versions of VSCode
activeTextEditor = await setupWorkspace(initialText, {
eol,
language,
});
emulator = new EmacsEmulator(activeTextEditor);

setEmptyCursors(activeTextEditor, [0, 3]);

await vscode.commands.executeCommand("default:type", { text: "\n" });
await clearTextEditor(activeTextEditor);
// XXX: (end of the workaround)

activeTextEditor = await setupWorkspace(initialText, {
eol,
language,
Expand Down

0 comments on commit 560b14a

Please sign in to comment.