fortls icon indicating copy to clipboard operation
fortls copied to clipboard

Signature help with nested parentheses displays wrong argument from argument list

Open JHenneberg opened this issue 2 years ago • 5 comments

Highlighting of current paramter in signature help is broken. This is happening only when the paramters are provided a way that involves a ,. In this case by accessing a value of an array.

  subroutine foo(arg1, arg2, arg3)
    implicit none

    integer(4), intent(in) :: arg1, arg2, arg3

    write(*, *) arg1, arg2, arg3

  end subroutine foo

  subroutine bar()
    implicit none

    integer(4) :: arr(4, 4)

    arr = 0

    call foo(arr(2, 3), ...) ! results in the below image, the comma in `arr(2, 3)` is causing the problem
  end subroutine bar

image

JHenneberg avatar Apr 13 '22 09:04 JHenneberg

This is part of the Signature help feature and I agree it needs work. The problem is that understanding literal nested scopes i.e. [2, 4, 5] or ar(1, 3) is a bit problematic. A while back I fixed this for simple literals (with the exception of complex numbers i think), but nesting them seems to be a big issue.

I have functions that are aimed at figuring these things out but robustly doing so is a bit of an issue.

gnikit avatar Apr 13 '22 10:04 gnikit

@gnikit , I couldn't reproduce the bug in fortls 2.13.1.dev166+g1f54125 which I install with pip install git+https://github.com/fortran-lang/fortls.git image

BUT, it is reproducable in fortls v2.13.0 image

So, could you advise me how to set unittest or set special flag to see both lines ( vriable and argument)?

folk85 avatar Jun 20 '23 17:06 folk85

@folk85 you can trigger the signature help, when you are typing the arguments of a function/subroutine and press ,. You would then be able to see the procedure's signature, and what argument you are meant to be typing.

gnikit avatar Jun 22 '23 12:06 gnikit

Yes, i see the signature help during typing, but i could not understand how generate unittest for this bug in dev build

folk85 avatar Jun 22 '23 12:06 folk85

Might want to have a look here to get some ideas https://github.com/fortran-lang/fortls/blob/master/test/test_server_signature_help.py

gnikit avatar Jun 22 '23 13:06 gnikit