errata-ai / vale-ls

:zap: An implementation of the Language Server Protocol (LSP) for the Vale command-line tool.
MIT License
63 stars 4 forks source link

vale-ls doesn't work on Windows (fix included) #9

Closed veksha closed 9 months ago

veksha commented 9 months ago

uri.path() will return /C:/file.txt on windows and call to vale.exe will fail. uri.path() is returning uri component called "path" (not what we want), i think it's better to use uri.to_file_path() to get file path in correct format.

diff --git a/src/server.rs b/src/server.rs
index c84f874..a3242c0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -380,7 +380,7 @@ impl Backend {

         self.update(params.clone());
         if self.cli.is_installed() {
-            match self.cli.run(uri.path(), self.config_path(), self.config_filter()) {
+            match self.cli.run(uri.to_file_path().unwrap().to_str().unwrap(), self.config_path(), self.config_filter()) {
                 Ok(result) => {
                     let mut diagnostics = Vec::new();
                     for (_, v) in result.iter() {
veksha commented 9 months ago

and i think it will solve https://github.com/errata-ai/vale-ls/issues/6 issue too. (because to_file_path will not do percent-encoding)

veksha commented 9 months ago

also to_file_path should be checked for errors, it can fail on urls like file:///Untitled1.

jdkato commented 9 months ago

Thanks for looking into this.

I can confirm that it fixes #6, but I can't test on Windows at the moment.

veksha commented 9 months ago

@jdkato, tested your commit on Windows. works fine. for new tabs which were not yet saved to files it outputs File path error: Some(()), but continues to work for other tabs.

jdkato commented 9 months ago

I'll make the log message more clear in the next release.