aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBrian Dawn2021-06-05 17:12:08 +0000
committerBlaž Hrastnik2021-06-06 01:49:17 +0000
commitf3db12e240868796257b9e57c5e39eb404723985 (patch)
treef7f0540411c4754817bfd45a1b9c15095010a009 /helix-core
parent676719b3614f6b3d2c97105e70a436f81ebfaa7b (diff)
Simplify the load_runtime_file code.
Reduce the number of feature switches for the embed_runtime feature.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 0bc6cb9d..e94c154d 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -81,18 +81,15 @@ fn load_runtime_file(language: &str, filename: &str) -> Result<String, std::io::
}
#[cfg(feature = "embed_runtime")]
-#[derive(rust_embed::RustEmbed)]
-#[folder = "../runtime/"]
-struct Runtime;
-
-#[cfg(feature = "embed_runtime")]
fn load_runtime_file(language: &str, filename: &str) -> Result<String, Box<dyn std::error::Error>> {
+ #[derive(rust_embed::RustEmbed)]
+ #[folder = "../runtime/"]
+ struct Runtime;
+
let path = PathBuf::from("queries").join(language).join(filename);
let query_bytes = Runtime::get(&path.display().to_string()).unwrap_or_default();
- std::str::from_utf8(query_bytes.as_ref())
- .map(|s| s.to_string())
- .map_err(|err| err.into())
+ String::from_utf8(query_bytes.to_vec()).map_err(|err| err.into())
}
fn read_query(language: &str, filename: &str) -> String {