Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix(rome_lsp): handle untitled files
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Mar 27, 2023
1 parent e68674c commit 5d210e6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/rome_lsp/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,14 @@ impl Session {
}

pub(crate) fn file_path(&self, url: &lsp_types::Url) -> Result<RomePath> {
let mut path_to_file = url
.to_file_path()
.map_err(|()| anyhow!("failed to convert {url} to a filesystem path"))?;
let mut path_to_file = match url.to_file_path() {
Err(_) => {
// if we can't create a path, it's probably because the file doesn't exist
// and it can a newly created file that it's not on disk
PathBuf::from(url.path())
}
Ok(path) => path,
};

let relative_path = self.initialize_params.get().and_then(|initialize_params| {
let root_uri = initialize_params.root_uri.as_ref()?;
Expand Down

0 comments on commit 5d210e6

Please sign in to comment.