Skip to content

Commit dfda674

Browse files
committed
feat(extension): add log and trace commands
1 parent be3e65e commit dfda674

7 files changed

Lines changed: 74 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Once installed, the extension automatically activates when you open a \`.vb\` fi
128128
4. Start coding with full IntelliSense support
129129

130130
If you have multiple solutions, use the Command Palette action **"VB.NET: Select Workspace Solution"** to choose the active \`.sln/.slnf/.slnx\`.
131+
For diagnostics, use **"VB.NET: Show Logs"** and **"VB.NET: Toggle LSP Trace"**.
131132

132133
## Architecture
133134

docs/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Last Updated: 2026-01-20
2626

2727
- **`VB.NET: Select Workspace Solution`** — choose a `.sln/.slnf/.slnx` file and update
2828
`vbnet.workspace.solutionPath`. Pick "Auto-detect" to clear the override.
29+
- **`VB.NET: Show Logs`** — opens the main output channel and the LSP trace channel.
30+
- **`VB.NET: Toggle LSP Trace`** — toggles `vbnet.trace.server` between `off` and `verbose`.
2931

3032
---
3133

src/extension/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,16 @@
220220
"title": "Select VB.NET Workspace Solution",
221221
"category": "VB.NET"
222222
},
223+
{
224+
"command": "vbnet.showLogs",
225+
"title": "Show VB.NET Logs",
226+
"category": "VB.NET"
227+
},
228+
{
229+
"command": "vbnet.toggleLspTrace",
230+
"title": "Toggle VB.NET LSP Trace",
231+
"category": "VB.NET"
232+
},
223233
{
224234
"command": "vbnet.showOutputChannel",
225235
"title": "Show VB.NET Output",

src/extension/src/extension.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@ function registerCommands(context: vscode.ExtensionContext): void {
188188
}
189189
})
190190
);
191+
192+
context.subscriptions.push(
193+
vscode.commands.registerCommand('vbnet.showLogs', async () => {
194+
outputChannel?.show();
195+
traceChannel?.show();
196+
outputChannel?.appendLine(`Log directory: ${context.logUri.fsPath}`);
197+
})
198+
);
199+
200+
context.subscriptions.push(
201+
vscode.commands.registerCommand('vbnet.toggleLspTrace', async () => {
202+
try {
203+
await toggleLspTrace();
204+
} catch (error) {
205+
const message = error instanceof Error ? error.message : String(error);
206+
outputChannel?.appendLine(`Failed to toggle LSP trace: ${message}`);
207+
vscode.window.showErrorMessage(`Failed to toggle LSP trace: ${message}`);
208+
}
209+
})
210+
);
191211
}
192212

193213
interface SolutionPickItem extends vscode.QuickPickItem {
@@ -299,6 +319,25 @@ async function solutionLikelyHasVbProjects(solutionPath: string): Promise<boolea
299319
}
300320
}
301321

322+
async function toggleLspTrace(): Promise<void> {
323+
const config = vscode.workspace.getConfiguration('vbnet');
324+
const current = config.get<string>('trace.server', 'off');
325+
const enabled = current === 'off';
326+
const next = enabled ? 'verbose' : 'off';
327+
328+
await config.update('trace.server', next, vscode.ConfigurationTarget.Workspace);
329+
330+
if (enabled) {
331+
traceChannel?.show();
332+
}
333+
334+
const message = enabled
335+
? 'VB.NET LSP trace enabled (verbose).'
336+
: 'VB.NET LSP trace disabled.';
337+
outputChannel?.appendLine(message);
338+
vscode.window.showInformationMessage(message);
339+
}
340+
302341
/**
303342
* Extension deactivation.
304343
* Called when the extension is deactivated.

test-explore/TEST_RESULTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ Optional flags:
4747

4848
## Recent runs
4949

50+
### 2026-01-22 — VS Code harness (VB.NET server, trace commands)
51+
52+
Command:
53+
- `cd test-explore\\clients\\vscode; npm test`
54+
55+
Outcome: PASS (14 passing, 5 pending; non-fatal DAP warnings)
56+
Notes:
57+
- DAP warnings: `Failed command 'threads' : 0x80004005` (during debug session).
58+
- DAP trace: `test-explore/clients/vscode/logs/dap-trace-2026-01-22T195827255Z.log`.
59+
5060
### 2026-01-22 — VS Code harness (VB.NET server)
5161

5262
Command:

test-explore/clients/vscode/src/suite/vbnet-extension.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ if (skipVbnetSmoke) {
275275

276276
try {
277277
assert.ok(commands.includes("vbnet.selectWorkspaceSolution"), "Select workspace solution command not registered.");
278+
assert.ok(commands.includes("vbnet.showLogs"), "Show logs command not registered.");
279+
assert.ok(commands.includes("vbnet.toggleLspTrace"), "Toggle LSP trace command not registered.");
278280
await config.update("trace.server", "verbose", vscode.ConfigurationTarget.Workspace);
279281
await config.update("server.transportType", "namedPipe", vscode.ConfigurationTarget.Workspace);
280282

test/VbNet.Extension.Tests.Vb/ExtensionManifestTests.vb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ Namespace VbNet.Extension.Tests
6363
Public Sub CommandsIncludeWorkspaceSolutionPicker()
6464
Dim root = LoadPackageJson()
6565
Dim commands = root.GetProperty("contributes").GetProperty("commands")
66+
Dim commandList = commands.EnumerateArray().Select(Function(item) item.GetProperty("command").GetString()).ToArray()
6667

67-
Dim hasCommand = commands.EnumerateArray().Any(Function(item) item.GetProperty("command").GetString() = "vbnet.selectWorkspaceSolution")
68-
Assert.True(hasCommand, "Expected vbnet.selectWorkspaceSolution to be contributed in package.json.")
68+
Dim required = New String() {
69+
"vbnet.selectWorkspaceSolution",
70+
"vbnet.showLogs",
71+
"vbnet.toggleLspTrace"
72+
}
73+
74+
For Each commandName In required
75+
Assert.Contains(commandName, commandList)
76+
Next
6977
End Sub
7078
End Class
7179

0 commit comments

Comments
 (0)