Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

### Fixed

- Fixed bug where type fields or methods were not detected if spaces were
used around `%`
([#286](https://github.com/fortran-lang/fortls/issues/286))
- Fixed bug where Go To Implementation would not work for submodules
([#74](https://github.com/fortran-lang/fortls/issues/74))
- Fixed bug where `associate` blocks for variables pointing to function results
Expand Down
6 changes: 5 additions & 1 deletion fortls/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ def get_var_stack(line: str) -> list[str]:
>>> get_var_stack('myarray(i)%foo%bar')
['myarray', 'foo', 'bar']

>>> get_var_stack('myarray( i ) % foo % bar')
['myarray', 'foo', 'bar']

In this case it will operate at the end of the string i.e. ``'this%foo'``

>>> get_var_stack('CALL self%method(this%foo')
Expand All @@ -569,13 +572,14 @@ def get_var_stack(line: str) -> list[str]:
# Continuation of variable after paren requires '%' character
iLast = 0
for i, section in enumerate(sections):
if not line[section.start : section.end].startswith("%"):
if not line[section.start : section.end].strip().startswith("%"):
iLast = i
final_var = ""
for section in sections[iLast:]:
final_var += line[section.start : section.end]

if final_var is not None:
final_var = "%".join([i.strip() for i in final_var.split("%")])
final_op_split: list[str] = FRegex.OBJBREAK.split(final_var)
return final_op_split[-1].split("%")
else:
Expand Down
23 changes: 23 additions & 0 deletions test/test_server_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,29 @@ def test_comp10():
validate_comp(results[i + 1], ref)


def test_comp11():
"""Indicate the derived types arguments separated with spaces and types"""
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
file_path = test_dir / "test_prog.f08"
string += comp_request(file_path, 23, 26)
string += comp_request(file_path, 27, 28)
string += comp_request(file_path, 28, 30)
string += comp_request(file_path, 29, 30)
errcode, results = run_request(string, ["--use_signature_help", "-n1"])
assert errcode == 0

exp_results = (
# test_prog.f08
[1, "val", "REAL(8)"],
[1, "val", "REAL(8)"],
[1, "val", "REAL(8)"],
[1, "val", "REAL(8)"],
)
assert len(exp_results) == len(results) - 1
for i, ref in enumerate(exp_results):
validate_comp(results[i + 1], ref)


def test_comp_import_host_association():
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)})
file_path = test_dir / "test_import.f90"
Expand Down
5 changes: 4 additions & 1 deletion test/test_source/test_prog.f08
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROGRAM test_program
REAL(8) :: x,y
COMPLEX(8) :: xc,yc
TYPE(vector) :: loc_vector
TYPE(scaled_vector) :: stretch_vector
TYPE(scaled_vector) :: stretch_vector, vector1d(1)
!
y = myfun(n,x)
CALL glob_sub(n,xc,yc)
Expand All @@ -25,4 +25,7 @@ PROGRAM test_program
!
CALL test_sig_Sub(a,b,opt2=c,opt3=d)
PRINT*, module_variable
y = stretch_vector%scale % val
y = stretch_vector % scale % val
y = vector1d( 1 ) % scale % val
END PROGRAM test_program