zeroc-ice / vscode-slice

Slice syntax highlighter for Visual Studio Code
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

Perform Url->Path Conversion for the Workspace Root During Initialization #34

Closed InsertCreativityHere closed 9 months ago

InsertCreativityHere commented 9 months ago

The only thing that actually changed

This line was added to where we initialize sessions: .and_then(|uri| uri.to_file_path().ok()) This line was removed from SliceConfig: if let Ok(root_path) = root.to_file_path() { They do the same thing: convert a uri to a path

Over-explaining stuff

We use root_uri for a single purpose: taking relative paths and making them absolute, so we can pass them to slicec. But, we don't actually use a uri for this. We convert the uri to PathBuf before we can actually use it.

Right now, when we initialize Session we store a Url, and SliceConfig will convert it to Pathbuf when it needs it. This PR changes this, so we perform the conversion immediately (during session initialization).

This means we only convert it once per server (instead of once for each configuration set), and if the user gives us a bogus path, we'll catch it immediately and report it, instead of 'catching' it later (SliceConfig actually just ignores the error).