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

Continue even if the lsp cannot acquire an exclusive lock #5740

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion forc-util/src/fs_locking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/core/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions sway-lsp/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
5 changes: 4 additions & 1 deletion sway-lsp/src/handlers/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ pub async fn handle_did_change_text_document(
state: &ServerState,
params: DidChangeTextDocumentParams,
) -> Result<(), LanguageServerError> {
document::mark_file_as_dirty(&params.text_document.uri)?;
if let Err(err) = document::mark_file_as_dirty(&params.text_document.uri) {
tracing::warn!("Failed to mark file as dirty: {}", err);
}

let (uri, session) = state
.sessions
.uri_and_session_from_workspace(&params.text_document.uri)
Expand Down
Loading