Skip to content

Fix #291 hover multi-line parameter signature #293

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

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fortls/parse_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ def parse(
_, col = find_word_in_line(line, name)
match = FRegex.PARAMETER_VAL.match(line[col:])
if match:
var = match.group(1).strip()
var = " ".join(match.group(1).strip().split())
new_var.set_parameter_val(var)

# Check if the "variable" is external and if so cycle
Expand Down
16 changes: 15 additions & 1 deletion test/test_server_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_hover_parameter_var_mul():
string += hover_req(file_path, 15, 28)
errcode, results = run_request(string, fortls_args=["--sort_keywords"])
assert errcode == 0
ref_results = ["```fortran90\nINTEGER, PARAMETER :: var_mul1 = 1 * 23\n```"]
ref_results = ["```fortran90\nINTEGER, PARAMETER :: var_mul1 = 1 * 23\n```"]
validate_hover(results, ref_results)


Expand All @@ -137,6 +137,20 @@ def test_hover_parameter_var_div():
validate_hover(results, ref_results)


def test_hover_parameter_var_multiline2():
"""Test that hover parameters display value correctly with
multiplication and spaces. Item 2"""
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
file_path = test_dir / "hover" / "parameters.f90"
string += hover_req(file_path, 17, 28)
errcode, results = run_request(string, fortls_args=["--sort_keywords"])
assert errcode == 0
ref_results = [
"```fortran90\nINTEGER, PARAMETER :: var_multi2 = 1 * 23 + 2 /1\n```"
]
validate_hover(results, ref_results)


def test_hover_parameter_nested():
"""Test that hover parameters using other parameter values works"""
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
Expand Down
3 changes: 3 additions & 0 deletions test/test_source/hover/parameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ program params
integer, parameter :: var_ex1 = 1 - 23
integer, parameter :: var_mul1 = 1 * 23
integer, parameter :: var_div1 = 1/1
INTEGER, PARAMETER :: var_multi2 = 1 * &
23 + &
2 /1 ! comment
end program params