-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
66 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as vscode from "vscode"; | ||
import { getParseTreeApi } from "../util/getExtensionApi"; | ||
|
||
export async function openNewEditor( | ||
content: string, | ||
language: string = "plaintext" | ||
) { | ||
await vscode.commands.executeCommand("workbench.action.closeAllEditors"); | ||
|
||
const document = await vscode.workspace.openTextDocument({ | ||
language, | ||
content, | ||
}); | ||
|
||
await (await getParseTreeApi()).loadLanguage(language); | ||
|
||
return await vscode.window.showTextDocument(document); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as assert from "assert"; | ||
import * as vscode from "vscode"; | ||
import * as sinon from "sinon"; | ||
import { getCursorlessApi } from "../../util/getExtensionApi"; | ||
import { openNewEditor } from "../openNewEditor"; | ||
|
||
suite("toggle decorations", async function () { | ||
this.timeout("100s"); | ||
this.retries(3); | ||
|
||
teardown(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
test("toggle decorations", () => runTest()); | ||
}); | ||
|
||
async function runTest() { | ||
const { hatTokenMap } = (await getCursorlessApi()).graph!; | ||
|
||
await openNewEditor("Hello world testing whatever"); | ||
|
||
// Check that hats appear by default | ||
await hatTokenMap.addDecorations(); | ||
assert((await hatTokenMap.getReadableMap(false)).getEntries().length !== 0); | ||
|
||
// Check that hats disappear when turned off | ||
await vscode.commands.executeCommand("cursorless.toggleDecorations"); | ||
await hatTokenMap.addDecorations(); | ||
assert((await hatTokenMap.getReadableMap(false)).getEntries().length === 0); | ||
|
||
// Check that hats reappear when turned back on | ||
await vscode.commands.executeCommand("cursorless.toggleDecorations"); | ||
await hatTokenMap.addDecorations(); | ||
assert((await hatTokenMap.getReadableMap(false)).getEntries().length !== 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters