@@ -2,6 +2,7 @@ import { mapValues, pickBy } from "lodash";
2
2
import { KeyMap , SectionName , TokenType } from "./TokenTypeHelpers" ;
3
3
import { SectionTypes , TokenTypeValueMap } from "./TokenTypes" ;
4
4
import { VscodeApi } from "@cursorless/vscode-common" ;
5
+ import { TextEditorCursorStyle } from "vscode" ;
5
6
6
7
const LEGACY_PLURAL_SECTION_NAMES : Record < string , string > = {
7
8
action : "actions" ,
@@ -11,9 +12,34 @@ const LEGACY_PLURAL_SECTION_NAMES: Record<string, string> = {
11
12
scope : "scopes" ,
12
13
} ;
13
14
15
+ /**
16
+ * Maps from the raw cursor style config value to the corresponding
17
+ * TextEditorCursorStyle enum value.
18
+ */
19
+ const cursorStyleMap = {
20
+ line : TextEditorCursorStyle . Line ,
21
+ block : TextEditorCursorStyle . Block ,
22
+ underline : TextEditorCursorStyle . Underline ,
23
+ [ "line-thin" ] : TextEditorCursorStyle . LineThin ,
24
+ [ "block-outline" ] : TextEditorCursorStyle . BlockOutline ,
25
+ [ "underline-thin" ] : TextEditorCursorStyle . UnderlineThin ,
26
+ } satisfies Record < string , TextEditorCursorStyle > ;
27
+
14
28
export class KeyboardConfig {
15
29
constructor ( private vscodeApi : VscodeApi ) { }
16
30
31
+ getCursorStyle ( ) : TextEditorCursorStyle {
32
+ const rawCursorStyle = this . vscodeApi . workspace
33
+ . getConfiguration ( "cursorless.experimental.keyboard.modal" )
34
+ . get < keyof typeof cursorStyleMap > ( "cursorStyle" ) ;
35
+
36
+ if ( rawCursorStyle == null ) {
37
+ return TextEditorCursorStyle . BlockOutline ;
38
+ }
39
+
40
+ return cursorStyleMap [ rawCursorStyle ] ;
41
+ }
42
+
17
43
/**
18
44
* Returns a keymap for a given config section that is intended to be further
19
45
* processed by eg {@link getSectionEntries} or {@link getSingularSectionEntry}.
0 commit comments