PMunch / nimlsp

Language Server Protocol implementation for Nim
MIT License
416 stars 50 forks source link

Fix infinite loop regression on Windows #141

Closed havardjohn closed 2 years ago

havardjohn commented 2 years ago

The issue is that an infinite loop occurs in every run of nimlsp following this commit in Nim: 23e0160af283bb0bb573a86145e6c1c792780d49.

splitFile has changed behavior on Windows. splitFile("D:").dir now returns "D:" instead of "". This behavior is now consistent with Linux's splitFile where splitFile("/").dir returns /.

The condition path != "/" in nimlsp code assumes that that the root component is a Linux root component. This adds support for Windows roots by using the platform-independent isRootDir proc. path.len > 0 is removed because "" counts as a root dir.

Fixes: #140

PMunch commented 2 years ago

Will this work for versions pre that comit as well? Otherwise I think we should keep the empty check in.

havardjohn commented 2 years ago

isRootDir considers "" root dir since Nim version 0.20 or before, so it's safe to remove the empty check.