Skip to content

Commit

Permalink
Revert "using instead the type help and the resolved keybindings"
Browse files Browse the repository at this point in the history
This reverts commit 1f450dd.
  • Loading branch information
meganrogge committed May 23, 2024
1 parent 1b60028 commit 12f0cf6
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/vs/editor/contrib/hover/browser/hoverAccessibleViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { format } from 'vs/base/common/strings';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { HoverController } from 'vs/editor/contrib/hover/browser/hoverController';
import { AccessibleViewType, AccessibleViewProviderId, AdvancedContentProvider, IAccessibleViewContentProvider, IAccessibleViewOptions } from 'vs/platform/accessibility/browser/accessibleView';
import { IAccessibleViewImplentation } from 'vs/platform/accessibility/browser/accessibleViewRegistry';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { HoverVerbosityAction } from 'vs/editor/common/languages';
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';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
Expand All @@ -22,14 +24,16 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle';

namespace HoverAccessibilityHelpNLS {
export const intro = localize('intro', "The hover widget is focused. Press the Tab key to cycle through the hover parts.");
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);
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);
export const increaseVerbosity = localize('increaseVerbosity', "- The focused hover part verbosity level can be increased ({0}).");
export const increaseVerbosityNoKb = localize('increaseVerbosityNoKb', "- The focused hover part verbosity level can be increased, which is currently not triggerable via keybinding.");
export const decreaseVerbosity = localize('decreaseVerbosity', "- The focused hover part verbosity level can be decreased ({0}).");
export const decreaseVerbosityNoKb = localize('decreaseVerbosityNoKb', "- The focused hover part verbosity level can be decreased, which is currently not triggerable via keybinding.");
export const hoverContent = localize('contentHover', "The last focused hover content is the following.");
}

export class HoverAccessibleView implements IAccessibleViewImplentation {

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

constructor(
private readonly _editor: ICodeEditor
private readonly _editor: ICodeEditor,
@IKeybindingService private readonly _keybindingService: IKeybindingService
) {
super();
this.options = {
language: this._editor.getModel()?.getLanguageId(),
type: AccessibleViewType.Help
type: AccessibleViewType.View
};
this._hoverController = HoverController.get(this._editor);
this._initializeActions();
Expand Down Expand Up @@ -155,12 +160,27 @@ export class HoverAccessibilityHelpProvider extends Disposable implements IAcces
if (!isActionSupported) {
return;
}
let actionId: string;
let descriptionWithKb: string;
let descriptionWithoutKb: string;
switch (action) {
case HoverVerbosityAction.Increase:
return HoverAccessibilityHelpNLS.increaseVerbosity;
actionId = INCREASE_HOVER_VERBOSITY_ACTION_ID;
descriptionWithKb = HoverAccessibilityHelpNLS.increaseVerbosity;
descriptionWithoutKb = HoverAccessibilityHelpNLS.increaseVerbosityNoKb;
break;
case HoverVerbosityAction.Decrease:
return HoverAccessibilityHelpNLS.decreaseVerbosity;
actionId = DECREASE_HOVER_VERBOSITY_ACTION_ID;
descriptionWithKb = HoverAccessibilityHelpNLS.decreaseVerbosity;
descriptionWithoutKb = HoverAccessibilityHelpNLS.decreaseVerbosityNoKb;
break;
}
return this._descriptionForCommand(actionId, descriptionWithKb, descriptionWithoutKb);
}

private _descriptionForCommand(commandId: string, msg: string, noKbMsg: string): string {
const kb = this._keybindingService.lookupKeybinding(commandId);
return kb ? format(msg, kb.getAriaLabel()) : format(noKbMsg, commandId);
}

private _descriptionOfFocusedMarkdownHover(hoverController: HoverController): string[] {
Expand Down

0 comments on commit 12f0cf6

Please sign in to comment.