-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Add command to announce editor line and column number #282152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| export const showAccessibilityHelpAction = nls.localize("showAccessibilityHelpAction", "Show Accessibility Help"); | ||
| export const listSignalSounds = nls.localize("listSignalSoundsCommand", "Run the command: List Signal Sounds for an overview of all sounds and their current status."); | ||
| export const listAlerts = nls.localize("listAnnouncementsCommand", "Run the command: List Signal Announcements for an overview of announcements and their current status."); | ||
| export const announceCursorPosition = nls.localize("announceCursorPosition", "Run the command: Announce Cursor Position{0} to hear the current line and column.", '<keybinding:editor.action.announceCursorPosition>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meganrogge Should we also add keybinding to this command?
I'm not sure if we want something along the line with ctrl+g which was the old "hacky" way of folks accessing this info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if alt/option+shift+g would be good ? @jooyoungseo and @rperez030 might know. We can ask on Friday!
|
|
||
| registerAction2(ToggleScreenReaderMode); | ||
|
|
||
| class AnnounceCursorPosition extends Action2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@meganrogge Do you think this would be the best/most appropriate place to register this command?
Other places I've been debating are:
src\vs\workbench\contrib\accessibilitySignals\browser\commands.tssrc\vs\workbench\contrib\accessibility\browser\accessibleViewActions.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new command editor.action.announceCursorPosition that announces the current cursor position (line and column) to screen reader users. This addresses an accessibility need where users want to quickly hear their current cursor location without navigating to the status bar.
Key Changes:
- New
AnnounceCursorPositionaction that uses the ARIAalert()function to announce position - Integration with accessibility help documentation to inform users about the new command
- Localized strings for the command title, description, and announcement message
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/workbench/contrib/codeEditor/browser/accessibility/accessibility.ts | Implements the new AnnounceCursorPosition command that retrieves the cursor position and announces it via screen reader |
| src/vs/workbench/contrib/accessibility/browser/editorAccessibilityHelp.ts | Adds reference to the new command in the accessibility help content |
| src/vs/editor/common/standaloneStrings.ts | Adds localized string for the accessibility help entry with keybinding placeholder |
|
|
||
| async run(accessor: ServicesAccessor): Promise<void> { | ||
| const codeEditorService = accessor.get(ICodeEditorService); | ||
| const editor = codeEditorService.getFocusedCodeEditor(); |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider also falling back to getActiveCodeEditor() if getFocusedCodeEditor() returns null. Many similar commands in the codebase use the pattern: codeEditorService.getFocusedCodeEditor() || codeEditorService.getActiveCodeEditor() to ensure the command works even when the editor doesn't have focus. Examples can be found in toggleColumnSelection.ts lines 81-85 and accessibleViewActions.ts line 328.
| const editor = codeEditorService.getFocusedCodeEditor(); | |
| const editor = codeEditorService.getFocusedCodeEditor() || codeEditorService.getActiveCodeEditor(); |
meganrogge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test (we should) but LGTM! We should test using status and alert and see how each behaves.
Resolves: #278855
TODO: Get recommendation on keyboard shortcut if we want them :)
TODO: Make sure files to register this announcement command are in proper location