Skip to content

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

Closed
@tomoto

Description

@tomoto

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions