Skip to content

Commit 12f0cf6

Browse files
committed
Revert "using instead the type help and the resolved keybindings"
This reverts commit 1f450dd.
1 parent 1b60028 commit 12f0cf6

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

src/vs/editor/contrib/hover/browser/hoverAccessibleViews.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55
import { localize } from 'vs/nls';
6+
import { format } from 'vs/base/common/strings';
67
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
78
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
89
import { AccessibleViewType, AccessibleViewProviderId, AdvancedContentProvider, IAccessibleViewContentProvider, IAccessibleViewOptions } from 'vs/platform/accessibility/browser/accessibleView';
910
import { IAccessibleViewImplentation } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
1011
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
1112
import { IHoverService } from 'vs/platform/hover/browser/hover';
1213
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
14+
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1315
import { HoverVerbosityAction } from 'vs/editor/common/languages';
1416
import { DECREASE_HOVER_VERBOSITY_ACCESSIBLE_ACTION_ID, DECREASE_HOVER_VERBOSITY_ACTION_ID, DECREASE_HOVER_VERBOSITY_ACTION_LABEL, INCREASE_HOVER_VERBOSITY_ACCESSIBLE_ACTION_ID, INCREASE_HOVER_VERBOSITY_ACTION_ID, INCREASE_HOVER_VERBOSITY_ACTION_LABEL } from 'vs/editor/contrib/hover/browser/hoverActionIds';
1517
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
@@ -22,14 +24,16 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
2224

2325
namespace HoverAccessibilityHelpNLS {
2426
export const intro = localize('intro', "The hover widget is focused. Press the Tab key to cycle through the hover parts.");
25-
export const increaseVerbosity = localize('increaseVerbosity', "- The focused hover part verbosity level can be increased with the Increase Hover Verbosity command<keybinding:{0}>.", INCREASE_HOVER_VERBOSITY_ACTION_ID);
26-
export const decreaseVerbosity = localize('decreaseVerbosity', "- The focused hover part verbosity level can be decreased with the Decrease Hover Verbosity command<keybinding:{0}>.", DECREASE_HOVER_VERBOSITY_ACTION_ID);
27+
export const increaseVerbosity = localize('increaseVerbosity', "- The focused hover part verbosity level can be increased ({0}).");
28+
export const increaseVerbosityNoKb = localize('increaseVerbosityNoKb', "- The focused hover part verbosity level can be increased, which is currently not triggerable via keybinding.");
29+
export const decreaseVerbosity = localize('decreaseVerbosity', "- The focused hover part verbosity level can be decreased ({0}).");
30+
export const decreaseVerbosityNoKb = localize('decreaseVerbosityNoKb', "- The focused hover part verbosity level can be decreased, which is currently not triggerable via keybinding.");
2731
export const hoverContent = localize('contentHover', "The last focused hover content is the following.");
2832
}
2933

3034
export class HoverAccessibleView implements IAccessibleViewImplentation {
3135

32-
readonly type = AccessibleViewType.Help;
36+
readonly type = AccessibleViewType.View;
3337
readonly priority = 95;
3438
readonly name = 'hover';
3539
readonly when = EditorContextKeys.hoverFocused;
@@ -66,12 +70,13 @@ export class HoverAccessibilityHelpProvider extends Disposable implements IAcces
6670
public onDidChangeContent: Event<void> = this._onDidChangeContent.event;
6771

6872
constructor(
69-
private readonly _editor: ICodeEditor
73+
private readonly _editor: ICodeEditor,
74+
@IKeybindingService private readonly _keybindingService: IKeybindingService
7075
) {
7176
super();
7277
this.options = {
7378
language: this._editor.getModel()?.getLanguageId(),
74-
type: AccessibleViewType.Help
79+
type: AccessibleViewType.View
7580
};
7681
this._hoverController = HoverController.get(this._editor);
7782
this._initializeActions();
@@ -155,12 +160,27 @@ export class HoverAccessibilityHelpProvider extends Disposable implements IAcces
155160
if (!isActionSupported) {
156161
return;
157162
}
163+
let actionId: string;
164+
let descriptionWithKb: string;
165+
let descriptionWithoutKb: string;
158166
switch (action) {
159167
case HoverVerbosityAction.Increase:
160-
return HoverAccessibilityHelpNLS.increaseVerbosity;
168+
actionId = INCREASE_HOVER_VERBOSITY_ACTION_ID;
169+
descriptionWithKb = HoverAccessibilityHelpNLS.increaseVerbosity;
170+
descriptionWithoutKb = HoverAccessibilityHelpNLS.increaseVerbosityNoKb;
171+
break;
161172
case HoverVerbosityAction.Decrease:
162-
return HoverAccessibilityHelpNLS.decreaseVerbosity;
173+
actionId = DECREASE_HOVER_VERBOSITY_ACTION_ID;
174+
descriptionWithKb = HoverAccessibilityHelpNLS.decreaseVerbosity;
175+
descriptionWithoutKb = HoverAccessibilityHelpNLS.decreaseVerbosityNoKb;
176+
break;
163177
}
178+
return this._descriptionForCommand(actionId, descriptionWithKb, descriptionWithoutKb);
179+
}
180+
181+
private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string {
182+
const kb = this._keybindingService.lookupKeybinding(commandId);
183+
return kb ? format(msg, kb.getAriaLabel()) : format(noKbMsg, commandId);
164184
}
165185

166186
private _descriptionOfFocusedMarkdownHover(hoverController: HoverController): string[] {

0 commit comments

Comments
 (0)