Repository navigation
Add a command to toggle TODO visibility - #6135
Conversation
f091b1b to
09322d9
Compare
This comment was marked as outdated.
This comment was marked as outdated.
09322d9 to
182939d
Compare
There was a problem hiding this comment.
🟡 Not ready to approve
The new toggle command has incorrect behaviour for array-valued dart.showTodos and may not correctly update WorkspaceFolder-scoped settings without a resource-scoped configuration.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds a new VS Code command to quickly toggle the dart.showTodos setting from the command palette, avoiding manual edits to settings JSON when iterating on lints and diagnostics.
Changes:
- Register
dart.toggleShowTodosand implement logic to flipdart.showTodosbetween enabled/disabled. - Add test coverage for toggling behaviour across user/workspace scopes (including multi-root coverage).
- Contribute the new command to
package.jsonso it’s discoverable in VS Code.
File summaries
| File | Description |
|---|---|
| src/extension/commands/analyzer.ts | Registers the new toggle command and updates dart.showTodos based on current configuration scope. |
| src/test/dart/commands/analyzer.test.ts | Adds single-root tests for toggling dart.showTodos in user/workspace settings. |
| src/test/multi_root/commands/analyzer.test.ts | Adds multi-root test coverage for workspace-scoped toggling behaviour. |
| package.json | Contributes the dart.toggleShowTodos command to VS Code. |
Review details
Comments suppressed due to low confidence (1)
src/extension/commands/analyzer.ts:64
- This command may select
ConfigurationTarget.WorkspaceFolder, butconfig.setShowTodos()ultimately callsworkspace.getConfiguration("dart")without a resource URI. VS Code requires a resource-scoped configuration to reliably update WorkspaceFolder settings, otherwise the update can fail or write to the wrong scope/folder. Consider using a resource-scoped configuration for bothinspect()andupdate().
let target = vs.ConfigurationTarget.Global;
const configValue = vs.workspace.getConfiguration("dart").inspect(settingName);
if (configValue?.workspaceFolderValue !== undefined) {
target = vs.ConfigurationTarget.WorkspaceFolder;
} else if (configValue?.workspaceValue !== undefined) {
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
7e4caab to
f504cbe
Compare
This only toggles as a bool though, so you can't set it to show TODO without HACK etc. Fixes #6118
There was a problem hiding this comment.
🟡 Not ready to approve
The command and multi-root test currently don’t correctly handle/validate workspace-folder scoped settings due to missing resource scoping for configuration inspection/updates.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Review details
Comments suppressed due to low confidence (2)
src/test/multi_root/commands/analyzer.test.ts:23
- This multi-root test is not actually exercising the folder-level (
WorkspaceFolder) configuration case:
refresh()usesgetConfiguration("dart")without a resource scope, soinspect()won’t reliably surfaceworkspaceFolderValue.- The test sets
ConfigurationTarget.Workspace(workspace file), but the title says the setting is defined in folder settings.
Adjust the test to scope the configuration to helloWorldMainFile and use ConfigurationTarget.WorkspaceFolder, then assert workspaceFolderValue is what gets toggled.
function refresh(): void {
config = vs.workspace.getConfiguration("dart");
}
beforeEach(async () => {
await activate(helloWorldMainFile);
refresh();
// Clear overrides to start from a clean state.
await config.update(settingName, undefined, vs.ConfigurationTarget.Global);
await config.update(settingName, undefined, vs.ConfigurationTarget.Workspace);
refresh();
});
it("toggles in Workspace settings when defined in Folder settings (multi-root workspace)", async () => {
await config.update(settingName, false, vs.ConfigurationTarget.Workspace);
src/extension/commands/analyzer.ts:69
workspace.getConfiguration("dart")is unscoped, soinspect("showTodos")will not reliably populateworkspaceFolderValuein multi-root workspaces and may update the wrong target. Also,config.setShowTodos(..., WorkspaceFolder)uses the global/unscopedConfigwrapper which doesn’t know which folder to write to.
Use a resource-scoped configuration (for example the active editor’s URI) and perform the update via that scoped WorkspaceConfiguration so folder/workspace/global targeting works correctly.
const currentValue = config.showTodos;
const newValue = !currentValue;
let target = vs.ConfigurationTarget.Global;
const configValue = vs.workspace.getConfiguration("dart").inspect(settingName);
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
|
f504cbe to
feae74e
Compare
This only toggles as a bool though, so you can't set it to show TODO without HACK etc.
Fixes #6118