Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectionRangeProvider on inner array always returns outer array #91852

Closed
fvclaus opened this issue Mar 1, 2020 · 6 comments
Closed

selectionRangeProvider on inner array always returns outer array #91852

fvclaus opened this issue Mar 1, 2020 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@fvclaus
Copy link

fvclaus commented Mar 1, 2020

Issue Type: Bug

Steps to Reproduce:

Execute selectionRangeProvider in an JSON array that is enclosed in another array. It will return the outer array. This behavior changed from 1.41.0 to 1.42.0. In 1.41.0 the inner array was returned.

enclosing_array

If the selectionrange provider is executed at the current position, it will return the top array (first and last line). In previous version, it returned the array from line 4-7.

I have created a repository with a single that demonstrates this behavior:

https://github.com/fvclaus/vscode-selectionrangeprovider/blob/master/src/test/suite/searchEnclosingArray.test.ts

npm run test will execute the test. The vscode version can be changed in src/test/runTests.ts

VS Code version: Code 1.42.1 (c47d83b, 2020-02-11T14:50:36.977Z)
OS version: Linux x64 4.15.0-74-generic snap

Does this issue occur when all extensions are disabled?: Yes

System Info
Item Value
CPUs AMD Ryzen 7 2700 Eight-Core Processor (16 x 2282)
GPU Status 2d_canvas: unavailable_software
flash_3d: disabled_software
flash_stage3d: disabled_software
flash_stage3d_baseline: disabled_software
gpu_compositing: disabled_software
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: disabled_off
rasterization: disabled_software
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: disabled_software
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 0, 1, 1
Memory (System) 23.55GB (4.92GB free)
Process Argv --force-user-env --no-sandbox --unity-launch --no-sandbox
Screen Reader no
VM 0%
Extensions (2)
Extension Author (truncated) Version
code-runner for 0.9.16
vscode-emacs-improved rkw 1.1.0
@vscodebot
Copy link

vscodebot bot commented Mar 1, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@aeschli
Copy link
Contributor

aeschli commented Mar 2, 2020

When I try your sample with the Expand Selection command, it seems to work correctly.
expand2

I tried with your test, but it various issues in the code: document is empty when breaking at the assert, position not as described in the issue.

@aeschli aeschli added the info-needed Issue requires more information from poster label Mar 2, 2020
@fvclaus
Copy link
Author

fvclaus commented Mar 2, 2020

Expand to selection works, I know. It must do something different.

Yes, the position in the document was wrong. Maybe I changed it by accident before pushing. Anyway, I fixed the position. If you pull again, you will see the correct position.

I think those issues you are referring to are linter issues? If so, they don't matter, but I fixed them anyway.

Here is a screenshot of an active debug session:

foo_array

And here is the value of selectionRanges:

[
  {
    "range": [
      {
        "line": 0,
        "character": 0
      },
      {
        "line": 11,
        "character": 1
      }
    ]
  }
]

@aeschli
Copy link
Contributor

aeschli commented Mar 2, 2020

It seems that the positions don't make it back to the JSON language server:

I add the following to the beginning of the test:

        vscode.languages.registerSelectionRangeProvider('json', {
            provideSelectionRanges(d, p) {
                console.log(JSON.stringify(p));
                return null;
            }
        });

When the test is run, the following is printed:
[{"line":null,"character":null}]

@aeschli aeschli assigned jrieken and unassigned aeschli Mar 2, 2020
@aeschli aeschli removed the info-needed Issue requires more information from poster label Mar 2, 2020
@jrieken
Copy link
Member

jrieken commented Mar 2, 2020

I can reproduce with our api command tests

Screenshot 2020-03-02 at 17 37 11

@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Mar 2, 2020
@jrieken jrieken added this to the March 2020 milestone Mar 2, 2020
@jrieken jrieken closed this as completed in fd487a7 Mar 3, 2020
@fvclaus
Copy link
Author

fvclaus commented Mar 22, 2020

I just tried it with 1.44-insider and my tests work again. Thanks!

@connor4312 connor4312 added author-verified verified Verification succeeded labels Apr 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants