Apply suggestions from code review

Co-authored-by: Ivan Tham <pickfire@riseup.net>
This commit is contained in:
Brian Dawn 2021-06-05 11:50:34 -05:00 committed by Blaž Hrastnik
parent 255598a2cb
commit ae105812d6
3 changed files with 4 additions and 8 deletions

View File

@ -45,7 +45,7 @@ # Installation
> NOTE: You should set this to <path to repository>/runtime in development (if > NOTE: You should set this to <path to repository>/runtime in development (if
> running via cargo). > running via cargo).
If you want to bake the `runtime/` directory into the Helix binary you can build If you want to embed the `runtime/` directory into the Helix binary you can build
it with: it with:
``` ```
@ -82,4 +82,3 @@ ### Keyboard shortcuts / Keymap
# Getting help # Getting help
Discuss the project on the community [Matrix Space](https://matrix.to/#/#helix-community:matrix.org) (make sure to join `#helix-editor:matrix.org` if you're on a client that doesn't support Matrix Spaces yet). Discuss the project on the community [Matrix Space](https://matrix.to/#/#helix-community:matrix.org) (make sure to join `#helix-editor:matrix.org` if you're on a client that doesn't support Matrix Spaces yet).

View File

@ -36,7 +36,7 @@ ## Build from source
runtime inside the same folder as the executable, but that can be overriden via runtime inside the same folder as the executable, but that can be overriden via
the `HELIX_RUNTIME` environment variable. the `HELIX_RUNTIME` environment variable.
If you want to bake the `runtime/` directory into the Helix binary you can build If you want to embed the `runtime/` directory into the Helix binary you can build
it with: it with:
``` ```

View File

@ -81,10 +81,7 @@ fn load_runtime_file(language: &str, filename: &str) -> Result<String, std::io::
} }
#[cfg(feature = "embed_runtime")] #[cfg(feature = "embed_runtime")]
use rust_embed::RustEmbed; #[derive(rust_embed::RustEmbed)]
#[cfg(feature = "embed_runtime")]
#[derive(RustEmbed)]
#[folder = "../runtime/"] #[folder = "../runtime/"]
struct Runtime; struct Runtime;
@ -93,7 +90,7 @@ fn load_runtime_file(language: &str, filename: &str) -> Result<String, Box<dyn s
let root = PathBuf::new(); let root = PathBuf::new();
let path = root.join("queries").join(language).join(filename); let path = root.join("queries").join(language).join(filename);
let query_bytes = Runtime::get(&path.as_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()) std::str::from_utf8(query_bytes.as_ref())
.map(|s| s.to_string()) .map(|s| s.to_string())
.map_err(|err| err.into()) .map_err(|err| err.into())