feat(#41): Open Cowriting Review Panel from markdown file/tab right-click
The review preview (`cowriting.showTrackChangesPreview`) was only reachable from the command palette and `ctrl+alt+r` — neither where a writer's hand naturally goes. Add the obvious right-click entry points to the plugin's central surface: - `explorer/context` + `editor/title/context` menu items gated on `resourceLangId == markdown`, both invoking `showTrackChangesPreview`. - The command now resolves the *clicked* document: it opens the passed Uri if it isn't already an open document (the Explorer case), instead of falling back to the active editor. No-arg invocation (palette / keybinding) is unchanged. - Retitle the command to "Open Cowriting Review Panel" so the menus read the operator's wording (palette shows "Cowriting: Open Cowriting Review Panel"). E2E: clicked-doc resolution (open + not-yet-open + no-arg fallback), both menu contributions present + markdown-gated, title, and keybinding unchanged. Closes #41. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -71,9 +71,16 @@ export class TrackChangesPreviewController implements vscode.Disposable {
|
||||
this.disposables.push(
|
||||
// F11 (SLICE-5): the editor/title gateway passes the tab's resource Uri;
|
||||
// the palette / keybinding pass nothing → fall back to the active editor.
|
||||
vscode.commands.registerCommand("cowriting.showTrackChangesPreview", (uri?: vscode.Uri) => {
|
||||
const byUri = uri && vscode.workspace.textDocuments.find((d) => d.uri.toString() === uri.toString());
|
||||
this.show(byUri || vscode.window.activeTextEditor?.document);
|
||||
// #41: the explorer/tab right-click also passes the clicked Uri, which may
|
||||
// not be an open document yet — open it so we preview the clicked file, not
|
||||
// whatever happens to be the active editor.
|
||||
vscode.commands.registerCommand("cowriting.showTrackChangesPreview", async (uri?: vscode.Uri) => {
|
||||
if (uri) {
|
||||
const open = vscode.workspace.textDocuments.find((d) => d.uri.toString() === uri.toString());
|
||||
this.show(open ?? (await vscode.workspace.openTextDocument(uri)));
|
||||
return;
|
||||
}
|
||||
this.show(vscode.window.activeTextEditor?.document);
|
||||
}),
|
||||
// F11: document-scoped Ask-Claude (also reused by #42's gateway). Edits the
|
||||
// active markdown doc; the rewrite is diffed into per-hunk F4 proposals.
|
||||
|
||||
Reference in New Issue
Block a user