Skip to content
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

Skip trying to substitute macros into lines that do not contain them #296

Merged
Merged
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
4 changes: 4 additions & 0 deletions fortls/parse_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -2234,6 +2234,10 @@ def replace_vars(line: str):

# Substitute (if any) read in preprocessor macros
for def_tmp, value in defs_tmp.items():
# Skip if the line does not contain the macro at all. This is supposed to
# spare the expensive regex-substitution in case we do not need it at all
if def_tmp not in line:
continue
def_regex = def_regexes.get(def_tmp)
if def_regex is None:
def_regex = re.compile(rf"\b{def_tmp}\b")
Expand Down