Skip to content

Commit 7844dc7

Browse files
committed
Fixed Literal hover signature shows incorrect length of string #55
Added unittests for both #54 and #55
1 parent 048a2f5 commit 7844dc7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- Fixed hovering value of literal and constant strings not displaying
88
([#54](https://github.com/gnikit/fortls/issues/54))
9+
- Fixed hovering string length size is now matching the string
10+
([#55](https://github.com/gnikit/fortls/issues/55))
911

1012
## 2.2.3
1113

fortls/langserver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ def create_signature_hover():
10551055
elif var_obj.desc.endswith("LOGICAL"):
10561056
hover_array.append(create_hover("LOGICAL", True))
10571057
elif var_obj.desc.endswith("STRING"):
1058-
hover_str = f"CHARACTER(LEN={len(var_obj.name)})"
1058+
hover_str = f"CHARACTER(LEN={len(var_obj.name)-2})"
10591059
hover_array.append(create_hover(hover_str, True))
10601060

10611061
# Include the signature if one is present e.g. if in an argument list

test/test_server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,12 @@ def check_return(result_array, checks):
575575
string += hover_req(file_path, 6, 28)
576576
string += hover_req(file_path, 7, 38)
577577
string += hover_req(file_path, 7, 55)
578+
string += hover_req(file_path, 8, 37)
579+
string += hover_req(file_path, 8, 50)
580+
string += hover_req(file_path, 9, 37)
581+
string += hover_req(file_path, 9, 48)
582+
string += hover_req(file_path, 10, 37)
583+
string += hover_req(file_path, 10, 48)
578584
file_path = test_dir / "hover" / "pointers.f90"
579585
string += hover_req(file_path, 1, 26)
580586
file_path = test_dir / "hover" / "functions.f90"

test/test_source/hover/parameters.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ program params
66
var*var2, &
77
var4 = 123
88
double precision, parameter :: somevar = 23.12, some = 1e-19
9+
logical(kind=8), parameter :: long_bool = .true.
10+
character(len=5), parameter :: sq_str = '12345'
11+
character(len=5), parameter :: dq_str = "12345"
912
end program params

0 commit comments

Comments
 (0)