Skip to content

if provideCommentingRanges(...) returns [] on first call later on the '+' button does not work #249716

Open
@mbehr1

Description

@mbehr1

Type: Bug

If an extension provides a commentController that on first call for a document returns [] but later returns a valid range the '+' to add a comment is show but only works once the document is made non-visible and then visible again.

This can be reproduced e.g. with the vscode-extension-sample 'comment-sample' and changing the provideCommentingRanges to:

commentController.commentingRangeProvider = {
		provideCommentingRanges: (document: vscode.TextDocument, _token: vscode.CancellationToken) => {
			const lineCount = document.lineCount;
			if (lineCount >1 ){
				return [new vscode.Range(0, 0, lineCount - 1, 0)];
			}else{
				return [];
			}
		}
	};

If you use an empty file/single line file the '+' button does not appear.
But once you do add some lines the '+' button to add a comment properly appears but doesn't show any reaction on pushing it.
Manually calling the command 'Add line comment' works though.
Only after this document with multiple lines is made non-visible and then visible again the '+' button now works properly.

Tried on both MacOS and Windows 11.

VS Code version: Code 1.100.2 (848b80a, 2025-05-14T21:47:40.416Z)
OS version: Darwin arm64 24.5.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 1, 2, 2
Memory (System) 16.00GB (0.07GB free)
Process Argv --crash-reporter-id 39b27cd9-4252-4af0-9e9d-d6c3a740ccee
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions