ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / workbench / services / keybinding / test / browser / keybindingIO.test.ts 190 строк · изменён 14 нояб., 04:52
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import assert from 'assert' ;
import { KeyChord, KeyCode, KeyMod, ScanCode } from '../../../../../base/common/keyCodes.js' ;
import { KeyCodeChord, decodeKeybinding, ScanCodeChord, Keybinding } from '../../../../../base/common/keybindings.js' ;
import { KeybindingParser } from '../../../../../base/common/keybindingParser.js' ;
import { OperatingSystem } from '../../../../../base/common/platform.js' ;
import { KeybindingIO, OutputBuilder } from '../../common/keybindingIO.js' ;
import { createUSLayoutResolvedKeybinding }
ResolvedKeybindingItem
ensureNoDisposablesAreLeakedInTestSuite
keybinding expected msg OperatingSystem
usLayoutResolvedKeybinding keybinding
actualSerialized usLayoutResolvedKeybinding
assert actualSerialized expected expected msg
keybinding expectedWin expectedMac expectedLinux
keybinding expectedWin OperatingSystem Windows
keybinding expectedMac OperatingSystem Macintosh
keybinding expectedLinux OperatingSystem Linux
keybinding _expected msg OperatingSystem
actualDeserialized KeybindingParser keybinding
expected _expected
assert actualDeserialized expected keybinding msg
inWin inMac inLinux expected
inWin expected OperatingSystem Windows
inMac expected OperatingSystem Macintosh
inLinux expected OperatingSystem Linux
keybinding expectedWin expectedMac expectedLinux
keybinding expectedWin expectedMac expectedLinux
expectedWin expectedMac expectedLinux keybinding
KeyCode Digit0
KeyCode KeyA
KeyCode UpArrow
KeyCode RightArrow
KeyCode DownArrow
KeyCode LeftArrow
KeyMod Alt KeyCode KeyA
KeyMod CtrlCmd KeyCode KeyA
KeyMod Shift KeyCode KeyA
KeyMod WinCtrl KeyCode KeyA
KeyMod CtrlCmd KeyMod Alt KeyCode KeyA
KeyMod CtrlCmd KeyMod Shift KeyCode KeyA
KeyMod CtrlCmd KeyMod WinCtrl KeyCode KeyA
KeyMod Shift KeyMod Alt KeyCode KeyA
KeyMod Shift KeyMod WinCtrl KeyCode KeyA
KeyMod Alt KeyMod WinCtrl KeyCode KeyA
KeyMod CtrlCmd KeyMod Shift KeyMod Alt KeyCode KeyA
KeyMod CtrlCmd KeyMod Shift KeyMod WinCtrl KeyCode KeyA
KeyMod Shift KeyMod Alt KeyMod WinCtrl KeyCode KeyA
KeyMod CtrlCmd KeyMod Shift KeyMod Alt KeyMod WinCtrl KeyCode KeyA
KeyMod CtrlCmd KeyCode KeyA KeyMod CtrlCmd KeyCode KeyA
KeyMod CtrlCmd KeyCode UpArrow KeyMod CtrlCmd KeyCode UpArrow
KeyCode Semicolon
KeyCode Equal
KeyCode Comma
KeyCode Minus
KeyCode Period
KeyCode Slash
KeyCode Backquote
KeyCode
KeyCode
KeyCode BracketLeft
KeyCode Backslash
KeyCode BracketRight
KeyCode Quote
KeyCode
KeyCode IntlBackslash
KeyCode Semicolon
KeyCode Equal
KeyCode Comma
KeyCode Minus
KeyCode Period
KeyCode Slash
KeyCode Backquote
KeyCode
KeyCode
KeyCode BracketLeft
KeyCode Backslash
KeyCode BracketRight
KeyCode Quote
KeyCode
KeyCode IntlBackslash
KeyMod CtrlCmd KeyMod Shift KeyMod Alt KeyMod WinCtrl KeyCode KeyA
KeyMod CtrlCmd KeyMod Shift KeyMod Alt KeyMod WinCtrl KeyCode KeyA
assert
KeybindingParser
ScanCode Comma KeyCode Slash
strJSON
userKeybinding Object strJSON
keybindingItem KeybindingIO userKeybinding
assert keybindingItem command
strJSON
userKeybinding Object strJSON
keybindingItem KeybindingIO userKeybinding
assert keybindingItem when
strJSON
userKeybinding Object strJSON
keybindingItem KeybindingIO userKeybinding
assert keybindingItem keybinding
strJSON
userKeybinding Object strJSON
keybindingItem KeybindingIO userKeybinding
assert keybindingItem keybinding
strJSON
userKeybinding Object strJSON
keybindingItem KeybindingIO userKeybinding
assert keybindingItem commandArgs text text
absent KeybindingIO Object
assert absent systemWide
invalid KeybindingIO Object
assert invalid systemWide
item KeybindingIO Object
assert item systemWide
resolvedKeybinding KeyMod CtrlCmd KeyMod WinCtrl KeyCode KeyA OperatingSystem Macintosh
item resolvedKeybinding
out
KeybindingIO out item
serialized out
assert serialized
readBack KeybindingIO Object serialized
assert readBack systemWide
assert readBack command
from
'../../../../../platform/keybinding/test/common/keybindingsTestUtils.js'
;
import
{
}
from
'../../../../../platform/keybinding/common/resolvedKeybindingItem.js'
;
import
{
}
from
'../../../../../base/test/common/utils.js'
;
suite
(
'keybindingIO'
,
(
)
=>
{
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'serialize/deserialize'
,
(
)
=>
{
function
testOneSerialization
(
:
number
,
:
string
,
:
string
,
OS
:
)
:
void
{
const
=
createUSLayoutResolvedKeybinding
(
,
OS
)
!
;
const
=
.
getUserSettingsLabel
(
)
;
.
strictEqual
(
,
,
+
' - '
+
)
;
}
function
testSerialization
(
:
number
,
:
string
,
:
string
,
:
string
)
:
void
{
testOneSerialization
(
,
,
'win'
,
.
)
;
testOneSerialization
(
,
,
'mac'
,
.
)
;
testOneSerialization
(
,
,
'linux'
,
.
)
;
}
function
testOneDeserialization
(
:
string
,
:
number
,
:
string
,
OS
:
)
:
void
{
const
=
.
parseKeybinding
(
)
;
const
=
decodeKeybinding
(
,
OS
)
;
.
deepStrictEqual
(
,
,
+
' - '
+
)
;
}
function
testDeserialization
(
:
string
,
:
string
,
:
string
,
:
number
)
:
void
{
testOneDeserialization
(
,
,
'win'
,
.
)
;
testOneDeserialization
(
,
,
'mac'
,
.
)
;
testOneDeserialization
(
,
,
'linux'
,
.
)
;
}
function
testRoundtrip
(
:
number
,
:
string
,
:
string
,
:
string
)
:
void
{
testSerialization
(
,
,
,
)
;
testDeserialization
(
,
,
,
)
;
}
testRoundtrip
(
.
,
'0'
,
'0'
,
'0'
)
;
testRoundtrip
(
.
,
'a'
,
'a'
,
'a'
)
;
testRoundtrip
(
.
,
'up'
,
'up'
,
'up'
)
;
testRoundtrip
(
.
,
'right'
,
'right'
,
'right'
)
;
testRoundtrip
(
.
,
'down'
,
'down'
,
'down'
)
;
testRoundtrip
(
.
,
'left'
,
'left'
,
'left'
)
;
testRoundtrip
(
.
|
.
,
'alt+a'
,
'alt+a'
,
'alt+a'
)
;
testRoundtrip
(
.
|
.
,
'ctrl+a'
,
'cmd+a'
,
'ctrl+a'
)
;
testRoundtrip
(
.
|
.
,
'shift+a'
,
'shift+a'
,
'shift+a'
)
;
testRoundtrip
(
.
|
.
,
'win+a'
,
'ctrl+a'
,
'meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'ctrl+alt+a'
,
'alt+cmd+a'
,
'ctrl+alt+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'ctrl+shift+a'
,
'shift+cmd+a'
,
'ctrl+shift+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'ctrl+win+a'
,
'ctrl+cmd+a'
,
'ctrl+meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'shift+alt+a'
,
'shift+alt+a'
,
'shift+alt+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'shift+win+a'
,
'ctrl+shift+a'
,
'shift+meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
,
'alt+win+a'
,
'ctrl+alt+a'
,
'alt+meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
|
.
,
'ctrl+shift+alt+a'
,
'shift+alt+cmd+a'
,
'ctrl+shift+alt+a'
)
;
testRoundtrip
(
.
|
.
|
.
|
.
,
'ctrl+shift+win+a'
,
'ctrl+shift+cmd+a'
,
'ctrl+shift+meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
|
.
,
'shift+alt+win+a'
,
'ctrl+shift+alt+a'
,
'shift+alt+meta+a'
)
;
testRoundtrip
(
.
|
.
|
.
|
.
|
.
,
'ctrl+shift+alt+win+a'
,
'ctrl+shift+alt+cmd+a'
,
'ctrl+shift+alt+meta+a'
)
;
testRoundtrip
(
KeyChord
(
.
|
.
,
.
|
.
)
,
'ctrl+a ctrl+a'
,
'cmd+a cmd+a'
,
'ctrl+a ctrl+a'
)
;
testRoundtrip
(
KeyChord
(
.
|
.
,
.
|
.
)
,
'ctrl+up ctrl+up'
,
'cmd+up cmd+up'
,
'ctrl+up ctrl+up'
)
;
testRoundtrip
(
.
,
';'
,
';'
,
';'
)
;
testRoundtrip
(
.
,
'='
,
'='
,
'='
)
;
testRoundtrip
(
.
,
','
,
','
,
','
)
;
testRoundtrip
(
.
,
'-'
,
'-'
,
'-'
)
;
testRoundtrip
(
.
,
'.'
,
'.'
,
'.'
)
;
testRoundtrip
(
.
,
'/'
,
'/'
,
'/'
)
;
testRoundtrip
(
.
,
'`'
,
'`'
,
'`'
)
;
testRoundtrip
(
.
ABNT_C1
,
'abnt_c1'
,
'abnt_c1'
,
'abnt_c1'
)
;
testRoundtrip
(
.
ABNT_C2
,
'abnt_c2'
,
'abnt_c2'
,
'abnt_c2'
)
;
testRoundtrip
(
.
,
'['
,
'['
,
'['
)
;
testRoundtrip
(
.
,
'\\'
,
'\\'
,
'\\'
)
;
testRoundtrip
(
.
,
']'
,
']'
,
']'
)
;
testRoundtrip
(
.
,
'\''
,
'\''
,
'\''
)
;
testRoundtrip
(
.
OEM_8
,
'oem_8'
,
'oem_8'
,
'oem_8'
)
;
testRoundtrip
(
.
,
'oem_102'
,
'oem_102'
,
'oem_102'
)
;
testDeserialization
(
'OEM_1'
,
'OEM_1'
,
'OEM_1'
,
.
)
;
testDeserialization
(
'OEM_PLUS'
,
'OEM_PLUS'
,
'OEM_PLUS'
,
.
)
;
testDeserialization
(
'OEM_COMMA'
,
'OEM_COMMA'
,
'OEM_COMMA'
,
.
)
;
testDeserialization
(
'OEM_MINUS'
,
'OEM_MINUS'
,
'OEM_MINUS'
,
.
)
;
testDeserialization
(
'OEM_PERIOD'
,
'OEM_PERIOD'
,
'OEM_PERIOD'
,
.
)
;
testDeserialization
(
'OEM_2'
,
'OEM_2'
,
'OEM_2'
,
.
)
;
testDeserialization
(
'OEM_3'
,
'OEM_3'
,
'OEM_3'
,
.
)
;
testDeserialization
(
'ABNT_C1'
,
'ABNT_C1'
,
'ABNT_C1'
,
.
ABNT_C1
)
;
testDeserialization
(
'ABNT_C2'
,
'ABNT_C2'
,
'ABNT_C2'
,
.
ABNT_C2
)
;
testDeserialization
(
'OEM_4'
,
'OEM_4'
,
'OEM_4'
,
.
)
;
testDeserialization
(
'OEM_5'
,
'OEM_5'
,
'OEM_5'
,
.
)
;
testDeserialization
(
'OEM_6'
,
'OEM_6'
,
'OEM_6'
,
.
)
;
testDeserialization
(
'OEM_7'
,
'OEM_7'
,
'OEM_7'
,
.
)
;
testDeserialization
(
'OEM_8'
,
'OEM_8'
,
'OEM_8'
,
.
OEM_8
)
;
testDeserialization
(
'OEM_102'
,
'OEM_102'
,
'OEM_102'
,
.
)
;
testDeserialization
(
'ctrl-shift-alt-win-a'
,
'ctrl-shift-alt-cmd-a'
,
'ctrl-shift-alt-meta-a'
,
.
|
.
|
.
|
.
|
.
)
;
testDeserialization
(
' ctrl-shift-alt-win-A '
,
' shift-alt-cmd-Ctrl-A '
,
' ctrl-shift-alt-META-A '
,
.
|
.
|
.
|
.
|
.
)
;
}
)
;
test
(
'deserialize scan codes'
,
(
)
=>
{
.
deepStrictEqual
(
.
parseKeybinding
(
'ctrl+shift+[comma] ctrl+/'
)
,
new
Keybinding
(
[
new
ScanCodeChord
(
true
,
true
,
false
,
false
,
.
)
,
new
KeyCodeChord
(
true
,
false
,
false
,
false
,
.
)
]
)
)
;
}
)
;
test
(
'issue #10452 - invalid command'
,
(
)
=>
{
const
=
` [{ "key": "ctrl+k ctrl+f", "command": ["firstcommand", "seccondcommand"] }] `
;
const
=
<
>
JSON
.
parse
(
)
[
0
]
;
const
=
.
readUserKeybindingItem
(
)
;
.
strictEqual
(
.
,
null
)
;
}
)
;
test
(
'issue #10452 - invalid when'
,
(
)
=>
{
const
=
` [{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [] }] `
;
const
=
<
>
JSON
.
parse
(
)
[
0
]
;
const
=
.
readUserKeybindingItem
(
)
;
.
strictEqual
(
.
,
undefined
)
;
}
)
;
test
(
'issue #10452 - invalid key'
,
(
)
=>
{
const
=
` [{ "key": [], "command": "firstcommand" }] `
;
const
=
<
>
JSON
.
parse
(
)
[
0
]
;
const
=
.
readUserKeybindingItem
(
)
;
.
deepStrictEqual
(
.
,
null
)
;
}
)
;
test
(
'issue #10452 - invalid key 2'
,
(
)
=>
{
const
=
` [{ "key": "", "command": "firstcommand" }] `
;
const
=
<
>
JSON
.
parse
(
)
[
0
]
;
const
=
.
readUserKeybindingItem
(
)
;
.
deepStrictEqual
(
.
,
null
)
;
}
)
;
test
(
'test commands args'
,
(
)
=>
{
const
=
` [{ "key": "ctrl+k ctrl+f", "command": "firstcommand", "when": [], "args": { "text": "theText" } }] `
;
const
=
<
>
JSON
.
parse
(
)
[
0
]
;
const
=
.
readUserKeybindingItem
(
)
;
.
strictEqual
(
(
.
as
unknown
as
{
:
string
}
)
.
,
'theText'
)
;
}
)
;
test
(
'systemWide - read defaults to false when absent or invalid'
,
(
)
=>
{
const
=
.
readUserKeybindingItem
(
<
>
JSON
.
parse
(
` { "key": "ctrl+cmd+a", "command": "firstcommand" } `
)
)
;
.
strictEqual
(
.
,
false
)
;
const
=
.
readUserKeybindingItem
(
<
>
JSON
.
parse
(
` { "key": "ctrl+cmd+a", "command": "firstcommand", "systemWide": "yes" } `
)
)
;
.
strictEqual
(
.
,
false
)
;
}
)
;
test
(
'systemWide - read parses boolean value'
,
(
)
=>
{
const
=
.
readUserKeybindingItem
(
<
>
JSON
.
parse
(
` { "key": "ctrl+cmd+a", "command": "firstcommand", "systemWide": true } `
)
)
;
.
strictEqual
(
.
,
true
)
;
}
)
;
test
(
'systemWide - write/export preserves the flag (roundtrip)'
,
(
)
=>
{
const
=
createUSLayoutResolvedKeybinding
(
.
|
.
|
.
,
.
)
!
;
const
=
new
ResolvedKeybindingItem
(
,
'workbench.action.openAgentsWindow'
,
undefined
,
undefined
,
false
,
null
,
false
,
true
)
;
const
=
new
OutputBuilder
(
)
;
.
writeKeybindingItem
(
,
)
;
const
=
.
toString
(
)
;
.
ok
(
.
includes
(
'"systemWide": true'
)
,
` expected serialized keybinding to include systemWide, got: ${ serialized} `
)
;
const
=
.
readUserKeybindingItem
(
<
>
JSON
.
parse
(
)
)
;
.
strictEqual
(
.
,
true
)
;
.
strictEqual
(
.
,
'workbench.action.openAgentsWindow'
)
;
}
)
;
}
)
;