diff --git a/forc-util/src/fs_locking.rs b/forc-util/src/fs_locking.rs index d35bec6c52d..ad1d8eaa438 100644 --- a/forc-util/src/fs_locking.rs +++ b/forc-util/src/fs_locking.rs @@ -71,7 +71,10 @@ impl PidFileLocking { if self.is_locked() { Err(io::Error::new( std::io::ErrorKind::Other, - "Cannot remove a dirty lock file, it is locked by another process", + format!( + "Cannot remove a dirty lock file, it is locked by another process (PID: {:#?})", + self.get_locker_pid() + ), )) } else { self.remove_file()?; diff --git a/sway-lsp/src/core/document.rs b/sway-lsp/src/core/document.rs index f40788c150c..2be01f262eb 100644 --- a/sway-lsp/src/core/document.rs +++ b/sway-lsp/src/core/document.rs @@ -115,7 +115,7 @@ pub fn mark_file_as_dirty(uri: &Url) -> Result<(), LanguageServerError> { let path = document::get_path_from_url(uri)?; Ok(PidFileLocking::lsp(path) .lock() - .map_err(|_| DirectoryError::LspLocksDirFailed)?) + .map_err(|e| DirectoryError::LspLocksDirFailed(e.to_string()))?) } /// Removes the corresponding flag file for the specifed Url. diff --git a/sway-lsp/src/error.rs b/sway-lsp/src/error.rs index c5277210537..e2bd6779a6c 100644 --- a/sway-lsp/src/error.rs +++ b/sway-lsp/src/error.rs @@ -54,8 +54,8 @@ pub enum DirectoryError { ManifestDirNotFound, #[error("Can't extract project name from {:?}", dir)] CantExtractProjectName { dir: String }, - #[error("Failed to create hidden .lsp_locks directory")] - LspLocksDirFailed, + #[error("Failed to create hidden .lsp_locks directory: {0}")] + LspLocksDirFailed(String), #[error("Failed to create temp directory")] TempDirFailed, #[error("Failed to canonicalize path")] diff --git a/sway-lsp/src/handlers/notification.rs b/sway-lsp/src/handlers/notification.rs index 05369de2dcf..be2e97211fa 100644 --- a/sway-lsp/src/handlers/notification.rs +++ b/sway-lsp/src/handlers/notification.rs @@ -78,7 +78,10 @@ pub async fn handle_did_change_text_document( state: &ServerState, params: DidChangeTextDocumentParams, ) -> Result<(), LanguageServerError> { - document::mark_file_as_dirty(¶ms.text_document.uri)?; + if let Err(err) = document::mark_file_as_dirty(¶ms.text_document.uri) { + tracing::warn!("Failed to mark file as dirty: {}", err); + } + let (uri, session) = state .sessions .uri_and_session_from_workspace(¶ms.text_document.uri)