-
Notifications
You must be signed in to change notification settings - Fork 57
/
dev.ts
45 lines (37 loc) · 1.11 KB
/
dev.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as vscode from "vscode";
import type { Argument } from ".";
import { Context, SelectionBehavior } from "../api";
import type { Extension } from "../state/extension";
/**
* Developer utilities for Dance.
*/
declare module "./dev";
/**
* Set the selection behavior of the specified mode.
*/
export function setSelectionBehavior(
_: Context,
extension: Extension,
mode?: Argument<string>,
value?: Argument<"caret" | "character">,
) {
const selectedMode = mode === undefined ? _.mode : extension.modes.get(mode);
if (selectedMode !== undefined) {
if (value === undefined) {
value = selectedMode.selectionBehavior === SelectionBehavior.Caret ? "character" : "caret";
}
selectedMode.update(
"_selectionBehavior",
value === "character" ? SelectionBehavior.Character : SelectionBehavior.Caret,
);
}
}
/**
* Copies the last encountered error message.
*/
export function copyLastErrorMessage(extension: Extension) {
if (extension.lastErrorMessage === undefined) {
return Promise.resolve();
}
return vscode.env.clipboard.writeText(extension.lastErrorMessage);
}