Skip to content

Commit bb3f6dc

Browse files
authored
Merge pull request #448 from tomoto/fix/strip-comment-for-fixed-format
fix: flip the condition in strip_comment for fixed format
2 parents 2ddad2a + 9f38ea4 commit bb3f6dc

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Unreleased
44

5+
### Fixed
6+
7+
- Fixed bug with Fixed Format references being incorrectly detected in comments
8+
([#447](https://github.com/fortran-lang/fortls/issues/447))
9+
510
## 3.1.2
611

712
### Fixed

fortls/parsers/internal/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ def get_code_line(
11371137
def strip_comment(self, line: str) -> str:
11381138
"""Strip comment from line"""
11391139
if self.fixed:
1140-
if FRegex.FIXED_COMMENT.match(line) and FRegex.FIXED_OPENMP.match(line):
1140+
if FRegex.FIXED_COMMENT.match(line) and not FRegex.FIXED_OPENMP.match(line):
11411141
return ""
11421142
else:
11431143
if FRegex.FREE_OPENMP.match(line) is None:

test/test_server_references.py

+9
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,12 @@ def test_references():
5151
[free_path, 78, 6, 12],
5252
),
5353
)
54+
55+
56+
def test_references_ignore_comments_fixed():
57+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "fixed")})
58+
file_path = test_dir / "fixed" / "comment_as_reference.f"
59+
string += ref_req(file_path, 3, 22)
60+
errcode, results = run_request(string)
61+
assert errcode == 0
62+
assert len(results[1]) == 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
program comment_as_reference
2+
C Comment with variable name gets picked as a ref: variable_to_reference
3+
real variable_to_reference
4+
variable_to_reference = 1
5+
end program comment_as_reference

0 commit comments

Comments
 (0)