mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-23 01:46:18 +04:00
Simplify the load_runtime_file code.
Reduce the number of feature switches for the embed_runtime feature.
This commit is contained in:
parent
676719b361
commit
f3db12e240
@ -80,19 +80,16 @@ fn load_runtime_file(language: &str, filename: &str) -> Result<String, std::io::
|
|||||||
std::fs::read_to_string(&path)
|
std::fs::read_to_string(&path)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "embed_runtime")]
|
|
||||||
#[derive(rust_embed::RustEmbed)]
|
|
||||||
#[folder = "../runtime/"]
|
|
||||||
struct Runtime;
|
|
||||||
|
|
||||||
#[cfg(feature = "embed_runtime")]
|
#[cfg(feature = "embed_runtime")]
|
||||||
fn load_runtime_file(language: &str, filename: &str) -> Result<String, Box<dyn std::error::Error>> {
|
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 path = PathBuf::from("queries").join(language).join(filename);
|
||||||
|
|
||||||
let query_bytes = Runtime::get(&path.display().to_string()).unwrap_or_default();
|
let query_bytes = Runtime::get(&path.display().to_string()).unwrap_or_default();
|
||||||
std::str::from_utf8(query_bytes.as_ref())
|
String::from_utf8(query_bytes.to_vec()).map_err(|err| err.into())
|
||||||
.map(|s| s.to_string())
|
|
||||||
.map_err(|err| err.into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_query(language: &str, filename: &str) -> String {
|
fn read_query(language: &str, filename: &str) -> String {
|
||||||
|
Loading…
Reference in New Issue
Block a user