Skip to content

Add a command to toggle TODO visibility - #6135

Merged
DanTup merged 1 commit into
masterfrom
add-toggle-todo-command
Jul 30, 2026
Merged

DanTup merged 1 commit into
masterfrom
add-toggle-todo-command

Conversation

@DanTup

@DanTup DanTup commented Jul 30, 2026

Copy link
Copy Markdown
Member

This only toggles as a bool though, so you can't set it to show TODO without HACK etc.

Fixes #6118

@DanTup DanTup added this to the v3.140.0 milestone Jul 30, 2026
@DanTup DanTup added is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix. in editor Relates to code editing or language features in commands Relates to commands (usually invoked from the command Palette) labels Jul 30, 2026
@DanTup
DanTup force-pushed the add-toggle-todo-command branch from f091b1b to 09322d9 Compare July 30, 2026 10:27
@codecov

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.toggleShowTodos and implement logic to flip dart.showTodos between enabled/disabled.
  • Add test coverage for toggling behaviour across user/workspace scopes (including multi-root coverage).
  • Contribute the new command to package.json so 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, but config.setShowTodos() ultimately calls workspace.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 both inspect() and update().
			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.

Comment thread src/extension/commands/analyzer.ts
Comment thread src/test/dart/commands/analyzer.test.ts Outdated
Comment thread src/test/multi_root/commands/analyzer.test.ts
@DanTup
DanTup force-pushed the add-toggle-todo-command branch 2 times, most recently from 7e4caab to f504cbe Compare July 30, 2026 13:00
@DanTup
DanTup requested a review from Copilot July 30, 2026 13:00
This only toggles as a bool though, so you can't set it to show TODO without HACK etc.

Fixes #6118

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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() uses getConfiguration("dart") without a resource scope, so inspect() won’t reliably surface workspaceFolderValue.
  • 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, so inspect("showTodos") will not reliably populate workspaceFolderValue in multi-root workspaces and may update the wrong target. Also, config.setShowTodos(..., WorkspaceFolder) uses the global/unscoped Config wrapper 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.

@DanTup

DanTup commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

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.

showTodos is window-scoped, so it'll never be workspace-folder scoped.

@DanTup
DanTup force-pushed the add-toggle-todo-command branch from f504cbe to feae74e Compare July 30, 2026 13:22
@DanTup
DanTup merged commit 699b542 into master Jul 30, 2026
5 checks passed
@DanTup
DanTup deleted the add-toggle-todo-command branch July 30, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in commands Relates to commands (usually invoked from the command Palette) in editor Relates to code editing or language features is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a command for toggling dart.showTodos value programatically

2 participants