microsoft / microsoft/TypeScript

Expand and shrink selection around JavaScript `if-elseif-else` statements

Open
#56,432 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Domain: LS: Smart-Select Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Acknowledgement
  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment

I am unsure if this is a bug or a feature request.

The expand and shrink selection does not work as expected around if-elseif-else statments.

    const a = 1;
    if (a === 1) {
      // foo
    } else if (a === 2) {
      // fii
    } else {
      // fum
    }

Actual behavior

Place the cursor between else if and try to expand selection. It expands like this.

Start
image

Middle (few more expansions needed to get here)
image

End (only one more expansion from the one above)
image

Expected behavior

I expected it to select it like this, starting from Middle above:

image
image
image
image

Additional context

VS Code version: Code 1.84.1 (2b35e1e6d88f1ce073683991d1eff5284a32690f, 2023-11-06T12:35:59.022Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.4.0-166-generic

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz (8 x 2611)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.69GB (17.72GB free)
Process Argv --crash-reporter-id e332dab4-91ea-49d1-8a1f-d8f6e06fa4e1
Screen Reader no
VM 0%
Item Value
Remote SSH: vm
OS Linux x64 5.4.0-166-generic
CPUs Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz (8 x 2394)
Memory (System) 31.32GB (23.28GB free)
VM 50%
Extensions (35)
Extension Author (truncated) Version
jest-snippets and 1.9.1
remote-containers ms- 0.321.0
remote-ssh ms- 0.107.0
remote-ssh-edit ms- 0.86.0
remote-wsl ms- 0.81.8
vscode-remote-extensionpack ms- 0.24.0
remote-explorer ms- 0.4.1
remote-server ms- 1.5.0
highlight-matching-tag vin 0.11.0
browserslist web 1.1.0
vscode-openapi 42C 4.18.6
lit-html bie 1.11.1
ruff cha 2023.44.0
vale-vscode chr 0.17.5
vscode-markdownlint Dav 0.52.0
vscode-eslint dba 2.4.2
gitlens eam 14.4.1
prettier-vscode esb 10.1.0
code-runner for 0.12.1
go gol 0.39.1
path-autocomplete ion 1.25.0
vscode-azureresourcegroups ms- 0.7.5
vscode-cosmosdb ms- 0.20.0
vscode-docker ms- 1.27.0
vscode-kubernetes-tools ms- 1.3.15
python ms- 2023.20.0
vscode-pylance ms- 2023.11.10
azure-account ms- 0.11.6
vscode-yaml red 1.14.0
vscode-direnv Rub 0.0.2
code-spell-checker str 3.0.1
vscode-stylelint sty 1.3.0
even-better-toml tam 0.19.2
shellcheck tim 0.34.0
vscode-proto3 zxh 0.5.5
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263cf:30880073
vscaat:30438848
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyonecf:30548226
2e4cg342:30602488
f6dab269:30613381
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
synctok:30869157
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixt:30871694
pythonregdiag2cf:30871583
pyreplss2:30879913
pythonmypyd1:30879173
pythoncet00cf:30874137
pythontbext0:30879054
dsvsc017cf:30880893
aa_t_chat:30882232

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reported expand and shrink selection behavior in VS Code using the JavaScript if/else-if/else example from the issue. Compare the actual and expected selection ranges shown in the screenshots, then trace the editor selection behavior to determine the affected entry point. Done means the selection expands and shrinks through the conditional structure as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.