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

Fixed format comments are not excluded from the reference search result #447

Open
tomoto opened this issue Dec 8, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@tomoto
Copy link

tomoto commented Dec 8, 2024

Describe the bug

When user performs the reference search (i.e., Go to /Peek /Find All References), the comments in the fixed format are not excluded from the result.

See the example below. When you perform "Find All References" to variable WORLD, the result includes the word "WORLD" in the comment that should be excluded.

The cause of this issue is rather obvious. The condition FRegex.FIXED_OPENMP.match(line) in the below code should be negated.

def strip_comment(self, line: str) -> str:
"""Strip comment from line"""
if self.fixed:
if FRegex.FIXED_COMMENT.match(line) and FRegex.FIXED_OPENMP.match(line):
return ""

To Reproduce

  1. Prepare a set of source codes in the fixed format.
  2. Perform {Go to|Peek|Find All} References over a symbol you choose. Make sure it gives you some (non empty) result.
  3. Comment out some of the references and try again.
  4. See the result still includes the comment that should be excluded.

Expected behavior

The comment should be excluded from the result of the reference search.

Screenshots & Animations

Nothing to add.

Setup information (please complete the following information):

  • OS: Linux
  • Python Version: 3.10.12
  • fortls Version: 3.1.3
  • Code editor used: VS Code
  • the Fortran extension for the code editor and its version: Modern Fortran v3.2.0

Configuration information (please complete the following information):

Nothing special.

Additional context

I will post a PR of the suggested fix. Just a second...

@tomoto
Copy link
Author

tomoto commented Dec 8, 2024

@gnikit PR posted at #448. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant