Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-core/src/uri.rs')
-rw-r--r--helix-core/src/uri.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/helix-core/src/uri.rs b/helix-core/src/uri.rs
index 4e03c58b..ddb9fb7a 100644
--- a/helix-core/src/uri.rs
+++ b/helix-core/src/uri.rs
@@ -1,4 +1,7 @@
-use std::path::{Path, PathBuf};
+use std::{
+ fmt,
+ path::{Path, PathBuf},
+};
/// A generic pointer to a file location.
///
@@ -47,6 +50,14 @@ impl TryFrom<Uri> for PathBuf {
}
}
+impl fmt::Display for Uri {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::File(path) => write!(f, "{}", path.display()),
+ }
+ }
+}
+
#[derive(Debug)]
pub struct UrlConversionError {
source: url::Url,
@@ -59,11 +70,16 @@ pub enum UrlConversionErrorKind {
UnableToConvert,
}
-impl std::fmt::Display for UrlConversionError {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+impl fmt::Display for UrlConversionError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.kind {
UrlConversionErrorKind::UnsupportedScheme => {
- write!(f, "unsupported scheme in URL: {}", self.source.scheme())
+ write!(
+ f,
+ "unsupported scheme '{}' in URL {}",
+ self.source.scheme(),
+ self.source
+ )
}
UrlConversionErrorKind::UnableToConvert => {
write!(f, "unable to convert URL to file path: {}", self.source)