Skip to content

Instantly share code, notes, and snippets.

@mqudsi
Created May 18, 2023 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mqudsi/39016c00c4313b9d4b11d8101c2a61e8 to your computer and use it in GitHub Desktop.
Save mqudsi/39016c00c4313b9d4b11d8101c2a61e8 to your computer and use it in GitHub Desktop.
diff --git a/fish-rust/src/env_dispatch.rs b/fish-rust/src/env_dispatch.rs
index 04a0a26be..416ed33f6 100644
--- a/fish-rust/src/env_dispatch.rs
+++ b/fish-rust/src/env_dispatch.rs
@@ -97,9 +97,8 @@ struct VarDispatchTable {
// TODO: Delete this after input_common is ported (and pass the input_function function directly).
fn update_wait_on_escape_ms(vars: &EnvStack) {
- let fish_escape_delay_ms = vars.get_unless_empty(L!("fish_escape_delay_ms"));
- let var = crate::env::environment::env_var_to_ffi(fish_escape_delay_ms);
- crate::ffi::update_wait_on_escape_ms_ffi(var);
+ let env_dyn = vars.snapshot();
+ crate::ffi::update_wait_on_escape_ms_ffi(Box::into_raw(env_dyn).cast());
}
impl VarDispatchTable {
diff --git a/src/input_common.cpp b/src/input_common.cpp
index 1f9b4db2d..dd16a7858 100644
--- a/src/input_common.cpp
+++ b/src/input_common.cpp
@@ -140,21 +140,10 @@ void update_wait_on_escape_ms(const environment_t& vars) {
}
}
-void update_wait_on_escape_ms_ffi(std::unique_ptr<env_var_t> fish_escape_delay_ms) {
- if (!fish_escape_delay_ms) {
- wait_on_escape_ms = WAIT_ON_ESCAPE_DEFAULT;
- return;
- }
-
- long tmp = fish_wcstol(fish_escape_delay_ms->as_string().c_str());
- if (errno || tmp < 10 || tmp >= 5000) {
- std::fwprintf(stderr,
- L"ignoring fish_escape_delay_ms: value '%ls' "
- L"is not an integer or is < 10 or >= 5000 ms\n",
- fish_escape_delay_ms->as_string().c_str());
- } else {
- wait_on_escape_ms = static_cast<int>(tmp);
- }
+void update_wait_on_escape_ms_ffi(const uint8_t *env_dyn_ptr) {
+ auto env_dyn = rust::Box<EnvDyn>::from_raw((EnvDyn*)env_dyn_ptr);
+ env_dyn_t vars(std::move(env_dyn));
+ update_wait_on_escape_ms(vars);
}
maybe_t<char_event_t> input_event_queue_t::try_pop() {
diff --git a/src/input_common.h b/src/input_common.h
index 976eb1d16..eb4f37c30 100644
--- a/src/input_common.h
+++ b/src/input_common.h
@@ -186,7 +186,7 @@ class char_event_t {
/// Adjust the escape timeout.
class environment_t;
void update_wait_on_escape_ms(const environment_t &vars);
-void update_wait_on_escape_ms_ffi(std::unique_ptr<env_var_t> fish_escape_delay_ms);
+void update_wait_on_escape_ms_ffi(const uint8_t *env_dyn_ptr);
/// A class which knows how to produce a stream of input events.
/// This is a base class; you may subclass it for its override points.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment