Skip to content

Regex pattern for include fails to catch slash #481

@hansolsuh

Description

@hansolsuh

Describe the bug

  1. Regex pattern issue
    I was trying to use #include "petsc/finclude/petscvec.h", but fortls couldn't not find it despite the correct dir locations. After doing some pdb walkthrough, I found that, at regex_patterns.py:133, has a "missing" slash. With the above line, the output was "petsc, when it should've been "petsc/finclude/petscvec.h"`.

I was able to get around this issue by adding a slash in the regex patter, via
[ ]*#[ ]*include[ ]*([\"\w\./]*)

Now, if I paste the original regex pattern into a separate python file, say, myexample.py, the original pattern does spit out "petsc/finclude/petscvec.h", but in the actual fortls code, it does not. Also, if I try it on pythex.org, the original pattern only gives `"petsc".

I tried it on both Ubuntu 22.04.5 LTS + Intel(R) Xeon(R) Gold 5317 CPU @ 3.00GHz, Python 3.10.12, and
M1 Macbook Air, Pthon 3.10.14.

Anyway, I got my fortran + petsc to work via that fix - wasn't sure whether you do not want regex for slash or not.

Thanks.

To Reproduce
Try and reproduce the fortls error through the debug interface, for more see fortls --debug_help. Usually debug requests start like fortls --debug_filepath your_file.f90 --debug_rootpath . ....

Start with posting:

  1. a Minimal Working Example to demonstrate the bug
  2. the fortls command to reproduce the issue, or your fortls
  3. the output of the fortls command
  4. Any additional JSONRPC requests like the ones produced with --debug_log

Alternatively, you can try and describe the steps that you followed to encounter the bug:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots & Animations
If applicable, add screenshots or GIF/MP4 animations to help explain your problem.

Setup information (please complete the following information):

  • OS: [e.g. Linux, Mac]
  • Python Version [e.g. 3.10]
  • fortls Version [e.g. 2.3]
  • Code editor used [e.g. VS Code, Vim]
  • the Fortran extension for the code editor and its version [e.g. Modern Fortran v3.0.0] (if applicable)

Configuration information (please complete the following information):

  • Your .fortlsrc or .fortls.json or .fortls configuration file OR any other JSON config being used (if any)
  • Any settings specified through your extension [e.g. for VS Code settings from settings.json]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions