Skip to content

[Bug] Empty ending bracket in "surroundingPairs" results in bad selection range #206774

@RedCMD

Description

@RedCMD
Contributor

add a bracket pair to "surroundingPairs" under language-configuration.json, with the end bracket being empty/blank

"surroundingPairs": [
    [ "(", "" ]
]

Make a selection around some text and press (
image

Expected: ✅
resulting selection is still around text
image

Actual: ❌
resulting selection ends up being moved 1 to the left
image

This could have been used as a workaround for #202386

Activity

added
editor-autoclosingEditor automatic closing of parens / brackets / etc.
bugIssue identified by VS Code Team member as probable bug
on Jun 12, 2024
RedCMD

RedCMD commented on Feb 13, 2025

@RedCMD
ContributorAuthor

results in console error:

log.ts:456   ERR Cannot read properties of undefined (reading 'range'): TypeError: Cannot read properties of undefined (reading 'range')
    at SurroundSelectionCommand.computeCursorState (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/commands/surroundSelectionCommand.js:22:63)
    at vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/cursor/cursor.js:653:55
    at EditStack._computeCursorState (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/model/editStack.js:364:42)
    at EditStack.pushEditOperation (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/model/editStack.js:351:44)
    at TextModel._pushEditOperations (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/model/textModel.js:1055:37)
    at TextModel.pushEditOperations (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/model/textModel.js:977:25)
    at CommandExecutor._innerExecuteCommands (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/cursor/cursor.js:634:41)
    at CommandExecutor.executeCommands (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/cursor/cursor.js:601:29)
    at CursorsController._executeEditOperation (vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/cursor/cursor.js:289:40)
    at vscode-file://vscode-app/e:/repos/vscode/vscode-main/out/vs/editor/common/cursor/cursor.js:458:26
RedCMD

RedCMD commented on Feb 13, 2025

@RedCMD
ContributorAuthor
added this to the July 2025 milestone on Jul 14, 2025
added
insiders-releasedPatch has been released in VS Code Insiders
and removed
unreleasedPatch has not yet been released in VS Code Insiders
on Jul 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugeditor-autoclosingEditor automatic closing of parens / brackets / etc.insiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @alexdima@RedCMD

    Issue actions

      [Bug] Empty ending bracket in `"surroundingPairs"` results in bad selection range · Issue #206774 · microsoft/vscode