Skip to content

web: release code -w -g file:line once the file's editor closes - #344740

Merged
Connor Peet (connor4312) merged 6 commits into
microsoft:mainfrom
cipheraxat:fix/342514-serve-web-wait-goto
Oct 28, 2026
Merged

Connor Peet (connor4312) merged 6 commits into
microsoft:mainfrom
cipheraxat:fix/342514-serve-web-wait-goto

Conversation

@cipheraxat

Copy link
Copy Markdown
Contributor

Fixes #342514

In the web workbench (code serve-web), code -w -g README.md:1 opens the file at the right line, but the command never exits after the tab is closed. Plain code -w README.md works.

BrowserHostService.openWindow strips the :line:col suffix with parseLineAndColumnAware only for the editor it opens. The --wait list was built from the raw file openables, so whenEditorClosed waited on README.md:1, which never matches the README.md editor that gets closed.

The wait list now strips line and column the same way when gotoLineMode is set, so it waits on the same resource that was opened. Merge mode and plain -w are unchanged. Diff mode is skipped on purpose, because the diff branch opens the raw URIs, so its wait list has to keep them. Desktop isn't affected because electron-main resolves the paths before it waits.

Added src/vs/workbench/services/host/test/browser/browserHostService.test.ts. It opens /workspace/README.md:3:5 with gotoLineMode and a wait marker, closes the README.md editor, and asserts that the marker file is deleted.

before after
editor opened README.md, selection 3:5 README.md, selection 3:5
wait marker deleted after close no (deleted: []) yes

Validation:

  • ./scripts/test.sh --run src/vs/workbench/services/host/test/browser/browserHostService.test.ts: fails on main, passes with the fix
  • ./scripts/test.sh --run src/vs/workbench/test/browser/parts/editor/editor.test.ts --run src/vs/base/test/common/extpath.test.ts: 30 passing
  • npm run eslint on both files, and tsc -p src/tsconfig.json --noEmit: clean

Not covered: I did not run a live code serve-web session. The fix is checked by the unit test above, which drives BrowserHostService.openWindow directly.

In the browser host, `--goto` paths are opened with the `:line:col`
suffix stripped, but the `--wait` list kept the raw path, so
`whenEditorClosed` never matched the closed editor and the CLI hung
(`code serve-web`). Strip the suffix the same way for the wait list.

Fixes microsoft#342514
Copilot AI balanced review requested due to automatic review settings October 28, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more reviewer sessions failed, leaving the review evidence incomplete.

No open issues 🎉

What changed in this PR

Fixes #342514 by making the web workbench’s code -w -g file:line wait for the actual opened resource, allowing the command to exit when its editor closes.

Changes:

  • Strips line and column suffixes from wait-list resources in goto mode, preserving existing merge and diff behavior.
  • Adds a regression test verifying the editor selection and wait-marker deletion after closure.
File Description
src/​vs/​workbench/​services/​host/​test/​browser/​browserHostService.test.ts Tests goto-mode opening and wait-marker cleanup.
src/​vs/​workbench/​services/​host/​browser/​browserHostService.ts Normalizes goto-mode resources before waiting for editor closure.

Review effort: Balanced

Only skip stripping `:line:col` when the diff branch actually ran
(`diffMode` with exactly two files), so a diff request that falls back
to the normal open still waits on the stripped resources. Collapse the
mapping to a single expression and drop test stubs that
`workbenchInstantiationService` overrides already provide.
@cipheraxat
Akshat Anand (cipheraxat) marked this pull request as ready for review October 28, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the --wait --goto URI-normalization change.

No open issues 🎉

Review effort: Balanced

@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) October 28, 2026 17:12
@connor4312
Connor Peet (connor4312) merged commit 448eafb into microsoft:main Oct 28, 2026
51 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.145.0 milestone Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

code -w -g file:line does not exit when the tab is closed (code serve-web only)

5 participants