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

Fix keyboard navigation commands #75

Merged
merged 3 commits into from
Feb 14, 2022

Conversation

Discookie
Copy link
Collaborator

Fixes #71.

@Discookie Discookie added this to the 1.1.1 milestone Feb 9, 2022
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the following test files:
main.h:

#ifndef MAIN_H
#define MAIN_H

int foo(int param) {
  return param;
}

#endif

main.cpp:

#include "main.h"

int main() {
  return 1 / foo(0);
}

If I analyze it CodeChecker will find the following report:
image

Let's assume that I click on the second bug step:
image

Now if I run the Next step command nothing happens:
image

I assumed that your patch fixes this use case so the editor will open main.h and select the correct ranges.

@Discookie
Copy link
Collaborator Author

That is a very good example for testing overlapping ranges, thank you!
Fixed it so it prioritizes exact matches over matching the step's range, but it still doesn't quite work in this case.

The issue is that the 2nd (calling foo) and 5th (returning from foo) steps have the exact same location. The extension has no memory of which step it's supposed to be on, so stepping backwards always steps from Calling and forwards from Returning.
Dealing with these exact overlaps is better fit for a separate issue I believe.

Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see what kind of problem this PR solves. Can you please describe the steps what previously don't work but with your patch it will work with a code example?

Also if we don't want to fix the problem fully could you please create another issue for it?

@Discookie
Copy link
Collaborator Author

Discookie commented Feb 14, 2022

It solves a simpler version of the issue:

main.cpp

#include "main.h"

int main() {
  return foo(0);
}

main.h

#ifndef MAIN_H
#define MAIN_H

int foo(int param) {
  return 1 / param;
}

#endif

In this case, navigation only worked inside main.h.
Also fixes range-checks in general, so the cursor can be anywhere in a report's range and the navigation will work.

Another added fix is for overlapping ranges:
( | is where the cursor jumps when you step to the repr. step.)

\-|----/ Step 1
    |-/  Step 2
    |    Cursor, stepping backwards.

Before, stepping backwards from step 2 skipped range 1, and jumped to step 1's previous step. Now when the cursor is on step 2's exact position, that one will get prioritized.

Created #86 for the remaining case.

Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@csordasmarton csordasmarton merged commit 468e442 into Ericsson:main Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard navigation between different files is broken
2 participants