Skip to content

Commit 094bab3

Browse files
committed
Fixes multiprocess bug
Closes Keywords always sorted on Windows #36
1 parent 01f8df3 commit 094bab3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
- Added coverage for `WHERE`, `ENUM`, max line/comment diagnostics and multilines
99
- Adds Windows CI
1010

11+
### Fixed
12+
13+
- Fixed global `sort_keywords` option not propagating during parsing on Windows
14+
([gnikit/fortls#36](https://github.com/gnikit/fortls/issues/36))
15+
1116
## 2.0.1
1217

1318
### Added

fortls/langserver.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,18 @@
6868
)
6969

7070

71-
def init_file(filepath, pp_defs, pp_suffixes, include_dirs):
71+
def init_file(filepath, pp_defs, pp_suffixes, include_dirs, sort):
7272
#
7373
file_obj = fortran_file(filepath, pp_suffixes)
7474
err_str, _ = file_obj.load_from_disk()
7575
if err_str:
7676
return None, err_str
7777
try:
78+
# On Windows multiprocess does not propage global variables through a shell.
79+
# Windows uses 'spawn' while Unix uses 'fork' which propagates globals.
80+
# This is a bypass.
81+
# For more see on SO: shorturl.at/hwAG1
82+
set_keyword_ordering(sort)
7883
file_ast = process_file(file_obj, pp_defs=pp_defs, include_dirs=include_dirs)
7984
except:
8085
log.error("Error while parsing file %s", filepath, exc_info=True)
@@ -1362,7 +1367,13 @@ def workspace_init(self):
13621367
for filepath in file_list:
13631368
results[filepath] = pool.apply_async(
13641369
init_file,
1365-
args=(filepath, self.pp_defs, self.pp_suffixes, self.include_dirs),
1370+
args=(
1371+
filepath,
1372+
self.pp_defs,
1373+
self.pp_suffixes,
1374+
self.include_dirs,
1375+
self.sort_keywords,
1376+
),
13661377
)
13671378
pool.close()
13681379
pool.join()

0 commit comments

Comments
 (0)