Fix #8: register warning stubs when no workspace folder; F5 opens the repo. Add selection context menus (#9)
- extension.ts: with no folder open, every contributed coauthoring command now
registers a warning stub ('open a folder first') instead of being absent —
the palette no longer errors 'command not found'. Opening a folder reloads
the window and re-activates with a real root.
- .vscode/launch.json: the EDH now opens the repo as its workspace, so plain
F5 lands in a working state.
- package.json: editor/context menu entries for 'Ask Claude to Edit
Selection' and 'Add Coauthoring Thread on Selection', shown only when text
is highlighted in a file-scheme editor (editorHasSelection).
- E2E: second no-workspace pass (suite-no-workspace) pins the #8 regression.
Fixes #8. Fixes #9.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import * as path from "path";
|
||||
import Mocha from "mocha";
|
||||
import { glob } from "glob";
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
const mocha = new Mocha({ ui: "tdd", color: true, timeout: 60000 });
|
||||
const testsRoot = path.resolve(__dirname);
|
||||
const files = await glob("**/*.test.js", { cwd: testsRoot });
|
||||
for (const f of files) mocha.addFile(path.resolve(testsRoot, f));
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
mocha.run((failures) => (failures > 0 ? reject(new Error(`${failures} E2E test(s) failed`)) : resolve()));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import * as assert from "assert";
|
||||
import * as vscode from "vscode";
|
||||
|
||||
// Regression for #8: with NO workspace folder open, activate() used to return
|
||||
// before registering the F2/F3 commands, so the palette errored with
|
||||
// "command 'cowriting.editSelection' not found". The fix registers warning
|
||||
// stubs instead. This suite runs in a second EDH pass launched WITHOUT a
|
||||
// folder (see runTest.ts).
|
||||
|
||||
suite("no-workspace activation (#8)", () => {
|
||||
test("EDH really has no workspace folder", () => {
|
||||
assert.strictEqual(vscode.workspace.workspaceFolders, undefined);
|
||||
});
|
||||
|
||||
test("all contributed coauthoring commands are registered as warning stubs", async () => {
|
||||
const ext = vscode.extensions.getExtension("benstull.vscode-cowriting-plugin")!;
|
||||
const api = await ext.activate();
|
||||
assert.strictEqual(api, undefined, "no-root activation returns no API");
|
||||
const all = await vscode.commands.getCommands(true);
|
||||
for (const command of [
|
||||
"cowriting.createThread",
|
||||
"cowriting.reply",
|
||||
"cowriting.resolveThread",
|
||||
"cowriting.reopenThread",
|
||||
"cowriting.editSelection",
|
||||
"cowriting.toggleAttribution",
|
||||
"cowriting.applyAgentEdit",
|
||||
]) {
|
||||
assert.ok(all.includes(command), `${command} is registered`);
|
||||
}
|
||||
});
|
||||
|
||||
test("invoking a stub does not throw (shows a warning instead)", async () => {
|
||||
await vscode.commands.executeCommand("cowriting.editSelection");
|
||||
await vscode.commands.executeCommand("cowriting.createThread");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user