Skip to content

Commit ce0bd7c

Browse files
authored
bug: Loosen file path requirement for discover command (#31)
Previously, we were expecting the path passed to `DiscoverArgument::Path` to be path to a file that already exists. However, it's possible that rust-analyzer will invoke us with a path to a not-yet-existing file if the user has opened a new file in their editor but hasn't yet saved. This commit removes the requirement that this path point to a file on disk to improve UX in this situation.
1 parent a893f20 commit ce0bd7c

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct CheckArgs {
9999
#[derive(PartialEq, Clone, Debug, Deserialize)]
100100
#[serde(rename_all = "camelCase")]
101101
pub enum DiscoverArgument {
102-
Path(FilePathBuf),
102+
Path(Utf8PathBuf),
103103
Buildfile(FilePathBuf),
104104
}
105105

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ fn discover(ctx: &Context, discover_args: DiscoverArgs, manifest_path: FilePath<
248248
}
249249

250250
fn check(ctx: &Context, command: &'static str, args: CheckArgs) -> Result<()> {
251-
let manifest = find_manifest(args.path)?;
251+
let manifest = find_manifest(args.path.into())?;
252252
let message_format = if ctx.is_tty {
253253
"--message-format=human"
254254
} else if args.disable_color_diagnostics {
@@ -281,7 +281,7 @@ fn check(ctx: &Context, command: &'static str, args: CheckArgs) -> Result<()> {
281281
}
282282
}
283283

284-
fn find_manifest(path: FilePathBuf) -> Result<FilePathBuf> {
284+
fn find_manifest(path: Utf8PathBuf) -> Result<FilePathBuf> {
285285
let path = std::path::absolute(&path)?;
286286
let Some(parent) = path.parent() else {
287287
anyhow::bail!("Invalid path: could not get parent");

0 commit comments

Comments
 (0)