microsoft / microsoft/vscode-cpptools

Brace matching does not account for inactive regions

Open
#3,681 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Language Service Visual Studio Code
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Issue Type: Bug

Capture17052019
please make test.cpp file using following code
#undef x
int main()
{
int a=0, b=0,c=0;
#ifndef x
if(b==2){
if(a==0){
}
else
#else
if(c==1){
#endif
a=1;
}// wrong matching
return 0;
}// wrong machine

Observe wrong bracket pairing at commented places. "// wrong machine"

Extension version: 0.23.1
VS Code version: Code 1.34.0 (a622c65b2c713c890fcf4fbf07cf34049d5fe758, 2019-05-15T21:59:37.030Z)
OS version: Windows_NT x64 6.1.7601

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz (4 x 2808)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: unavailable_off
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: unavailable_off
Load (avg) undefined
Memory (System) 15.89GB (7.41GB free)
Process Argv
Screen Reader no
VM 0%

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 issue by creating test.cpp with the preprocessor example in the report and checking the brace pairing around the inactive region. Trace the extension's brace-matching behavior for #ifndef, #else, and #endif; done means the braces are paired according to the active code paths rather than the inactive branch.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.