keybindingResolver.ts ×11

Frontier kind: Code frontier

unlabeled · c_a3f73a95b886

51 tests · 7587 LOC · 37 files · introduces 0 tests · 48 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges48 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1130 ranges7587 lines · 37 files · Browse complete extent
All tests (intent)
51 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 48 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/keybinding/common/keybindingResolver.ts 36 introduced LOC · 11 ranges

Open complete file

60 this._defaultBoundCommands = new Map<string, boolean>();
61 for (const defaultKeybinding of defaultKeybindings) {
62 > const command = defaultKeybinding.command; keybindingResolver.ts
63 > if (command && command.charAt(0) !== '-') {
64 > this._defaultBoundCommands.set(command, true);
65 > }
66 > }
67
68 this._map = new Map<string, ResolvedKeybindingItem[]>();
71 this._keybindings = KeybindingResolver.handleRemovals(([] as ResolvedKeybindingItem[]).concat(defaultKeybindings).concat(overrides));
72 for (let i = 0, len = this._keybindings.length; i < len; i++) {
73 > const k = this._keybindings[i]; keybindingResolver.ts
74 > if (k.chords.length === 0) {
75 // unbound
76 continue;
77 }
79 > // substitute with constants that are registered after startup - https://github.com/microsoft/vscode/issues/174218#issuecomment-1437972127
80 > const when = k.when?.substituteConstants();
81 >
82 > if (when && when.type === ContextKeyExprType.False) {
83 // when condition is false
84 continue;
85 }
87 > this._addKeyPress(k.chords[0], k);
88 > }
89 }
90
126 const removals = new Map</* commandId */ string, ResolvedKeybindingItem[]>();
127 for (let i = 0, len = rules.length; i < len; i++) {
128 > const rule = rules[i]; keybindingResolver.ts
129 > if (rule.command && rule.command.charAt(0) === '-') {
130 const command = rule.command.substring(1);
131 if (!removals.has(command)) {
176
177 private _addKeyPress(keypress: string, item: ResolvedKeybindingItem): void {
179 > const conflicts = this._map.get(keypress);
180 >
181 > if (typeof conflicts === 'undefined') {
182 > // There is no conflict so far
183 > this._map.set(keypress, [item]);
184 > this._addToLookupMap(item);
185 > return;
186 > }
187
188 for (let i = conflicts.length - 1; i >= 0; i--) {
216 conflicts.push(item);
217 this._addToLookupMap(item);
219
220 private _addToLookupMap(item: ResolvedKeybindingItem): void {
221 > if (!item.command) { keybindingResolver.ts
222 return;
223 }
225 > let arr = this._lookupMap.get(item.command);
226 > if (typeof arr === 'undefined') {
227 > arr = [item];
228 > this._lookupMap.set(item.command, arr);
229 > } else {
230 arr.push(item);
231 }
233
234 private _removeFromLookupMap(item: ResolvedKeybindingItem): void {
src/vs/platform/keybinding/common/resolvedKeybindingItem.ts 12 introduced LOC · 2 ranges

Open complete file

28
29 constructor(resolvedKeybinding: ResolvedKeybinding | undefined, command: string | null, commandArgs: any, when: ContextKeyExpression | undefined, isDefault: boolean, extensionId: string | null, isBuiltinExtension: boolean, systemWide: boolean = false) {
30 > this.resolvedKeybinding = resolvedKeybinding; resolvedKeybindingItem.ts
31 > this.chords = resolvedKeybinding ? toEmptyArrayIfContainsNull(resolvedKeybinding.getDispatchChords()) : [];
32 > if (resolvedKeybinding && this.chords.length === 0) {
33 // handle possible single modifier chord keybindings
34 this.chords = toEmptyArrayIfContainsNull(resolvedKeybinding.getSingleModifierDispatchChords());
35 }
36 > this.bubble = (command ? command.charCodeAt(0) === CharCode.Caret : false); resolvedKeybindingItem.ts
37 > this.command = this.bubble ? command!.substr(1) : command;
38 > this.commandArgs = commandArgs;
39 > this.when = when;
40 > this.isDefault = isDefault;
41 > this.extensionId = extensionId;
42 > this.isBuiltinExtension = isBuiltinExtension;
43 > this.systemWide = systemWide;
44 > }
45 }
46