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

Add a command to navigate to the matching #if/#ifdef/#else/#endif #4779

Closed
llHoYall opened this issue Dec 21, 2019 · 7 comments
Closed

Add a command to navigate to the matching #if/#ifdef/#else/#endif #4779

llHoYall opened this issue Dec 21, 2019 · 7 comments
Assignees
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@llHoYall
Copy link

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 Pro 1903 18362.535
  • VS Code Version: 1.41.1
  • C/C++ Extension Version: 0.26.2
  • Other extensions you installed (and if the issue persists after disabling them):
  • A clear and concise description of what the bug is.

To Reproduce

Expected behavior

if I press the specific key, then the cursor moves to matching pair.
#if <-> #endif
#if <-> #elif <-> #else <-> #endif
#ifdef <-> #endif

Screenshots

Additional context

@sean-mcmanus
Copy link
Collaborator

This is similar to #2565 (highlight of matching preprocessors).

However, the fix for #407 (preprocessor code folding) may fix this via usage of VS Code's "Go to Bracket" command.

@bobbrow bobbrow added this to the Backlog milestone Jan 9, 2020
@yushiyangk
Copy link

#407 has been implemented, but it seems "Go to Bracket" does not work, nor afaict anything else.

@sean-mcmanus
Copy link
Collaborator

@yushiyangk Yeah, looks like we'd have to add a new command.

@Colengms
Copy link
Collaborator

Colengms commented Jan 8, 2021

This should be pretty simple to support. The FoldingRangeProvider could keep a per-file mapping of folding ranges (instead of discarding them after they are returned to VS Code, which is what it currently does). We might want to limit that to just S_BM_IFDEF and possibly S_BM_REGION range types. A command could be added which checks the current cursor position, looks for a start/end on that line, and moves the cursor to the other line. It might be necessary to adjust the end line by +1/-1, as I think ranges will end on the line prior to the #endif, #else or #pragma endregion statement.

@Colengms Colengms changed the title How can I go to the matching preprocessor? Add a command to navigate to the matching #if/#ifdef/#else/#endif Jan 8, 2021
@Colengms Colengms modified the milestones: Backlog, On Deck Jan 22, 2021
@Colengms Colengms modified the milestones: On Deck, 1.3.0 Feb 2, 2021
@Colengms Colengms self-assigned this Feb 2, 2021
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Apr 1, 2021
@heartacker
Copy link

unfortunately, when in multifolder workspace, it will show a popup window which chosing the workspace when using command GoToPrevDirectiveInGroup and GoToNextDirectiveInGroup

@sean-mcmanus
Copy link
Collaborator

@heartacker I've moved that to #7283. It'll be fixed in our next 1.3.0-insiders4 release (some time next week).

@Colengms
Copy link
Collaborator

This feature was added in 1.3.0.

@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

6 participants