fix(edit-selection): accurate warnings + path-boundary workspace check #24
Reference in New Issue
Block a user
Delete Branch "fix-editselection-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Reported during F7 manual testing: "Ask Claude to Edit Selection" warned "I need to highlight text" even though text was selected. Root cause —
cowriting.editSelection's guard collapsed four distinct failures (no editor / no selection / unsaved / file outside the workspace folder) into one misleading "select some text in a workspace document first" message. The file (vscode-cowriting-plugin-content/issues/diff-view-toggle.md) was outside the EDH workspace root (.../vscode-cowriting-plugin/sandbox), so the membership check rejected it — but blamed the selection.Changes
src/workspacePath.ts:isUnderRoot(fsPath, root)— separator-bounded membership, fixing a latentstartsWith()prefix-collision (a sibling whose name prefixes the root —vscode-cowriting-plugin-contentvsvscode-cowriting-plugin— falsely matched).selectionRejection(ctx)— one accurate message per condition (the out-of-workspace case now says so explicitly, not "select some text").isUnderRootinto all five membership checks:extension.ts(editSelection guard +renderIfOpen) and the thread / attribution / proposal controllers.Test Plan
test/workspacePath.test.ts(8 cases) incl. the reported bug (out-of-workspace file → outside-workspace message, NOT the no-selection message) and the prefix-collision case.npm test— 130 passing (122 + 8).npm run test:e2e— 33 + 4 passing (existing F2–F7 suites exercise the membership checks through real workspace fixtures = regression guard forisUnderRoot).npm run typecheckclean.Not an F7 regression —
editSelectionwas last touched by F6 (#19). Session 0022.Co-authored with Claude.