diff options
author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-04-14 01:41:40 +0530 |
---|---|---|
committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-04-14 01:41:40 +0530 |
commit | 6d40a2adb9c27e644df9c47d0ba4982d182f7f09 (patch) | |
tree | 1fb2b72df4f34c3dac8a6b52d03c748748eb6742 | |
parent | 2c992367ad645284ea8d4ceedbae7489d96a5cb4 (diff) |
Fix after rebase
-rw-r--r-- | Cargo.lock | 89 | ||||
-rw-r--r-- | build.rs | 28 | ||||
-rw-r--r-- | src/cli.rs | 4 | ||||
-rw-r--r-- | src/client/mod.rs | 36 | ||||
-rw-r--r-- | src/client/panes/terminal_pane.rs | 1 | ||||
-rw-r--r-- | src/client/tab.rs | 2 | ||||
-rw-r--r-- | src/common/errors.rs | 2 | ||||
-rw-r--r-- | src/common/input/handler.rs | 81 | ||||
-rw-r--r-- | src/common/mod.rs | 13 | ||||
-rw-r--r-- | src/common/os_input_output.rs | 8 | ||||
-rw-r--r-- | src/common/pty_bus.rs | 112 | ||||
-rw-r--r-- | src/common/screen.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/server/mod.rs | 85 | ||||
-rw-r--r-- | src/tests/fakes.rs | 16 |
15 files changed, 194 insertions, 290 deletions
diff --git a/Cargo.lock b/Cargo.lock index 40d9370d6..cc7310344 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,9 +209,9 @@ dependencies = [ [[package]] name = "bincode" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d175dfa69e619905c4c3cdb7c3c203fa3bdd5d51184e3afdb2742c0280493772" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ "serde", ] @@ -265,9 +265,9 @@ checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cache-padded" @@ -491,9 +491,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06d4a9551359071d1890820e3571252b91229e0712e7c36b08940e603c5a8fc" +checksum = "e9d6ddad5866bb2170686ed03f6839d31a76e5407d80b1c334a2c24618543ffa" dependencies = [ "darling_core", "darling_macro", @@ -501,9 +501,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b443e5fb0ddd56e0c9bfa47dc060c5306ee500cb731f2b91432dd65589a77684" +checksum = "a9ced1fd13dc386d5a8315899de465708cf34ee2a6d9394654515214e67bb846" dependencies = [ "fnv", "ident_case", @@ -515,9 +515,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0220073ce504f12a70efc4e7cdaea9e9b1b324872e7ad96a208056d7a638b81" +checksum = "0a7a1445d54b2f9792e3b31a3e715feabbace393f38dc4ffd49d94ee9bc487d5" dependencies = [ "darling_core", "quote", @@ -637,9 +637,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "futures" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f55667319111d593ba876406af7c409c0ebb44dc4be6132a783ccf163ea14c1" +checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253" dependencies = [ "futures-channel", "futures-core", @@ -652,9 +652,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2dd2df839b57db9ab69c2c9d8f3e8c81984781937fe2807dc6dcf3b2ad2939" +checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25" dependencies = [ "futures-core", "futures-sink", @@ -662,15 +662,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15496a72fabf0e62bdc3df11a59a3787429221dd0710ba8ef163d6f7a9112c94" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" [[package]] name = "futures-executor" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891a4b7b96d84d5940084b2a37632dd65deeae662c114ceaa2c879629c9c0ad1" +checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d" dependencies = [ "futures-core", "futures-task", @@ -679,9 +679,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71c2c65c57704c32f5241c1223167c2c3294fd34ac020c807ddbe6db287ba59" +checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04" [[package]] name = "futures-lite" @@ -700,9 +700,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea405816a5139fb39af82c2beb921d52143f556038378d6db21183a5c37fbfb7" +checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -712,21 +712,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85754d98985841b7d4f5e8e6fbfa4a4ac847916893ec511a2917ccd8525b8bb3" +checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23" [[package]] name = "futures-task" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa189ef211c15ee602667a6fcfe1c1fd9e07d42250d2156382820fba33c9df80" +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" [[package]] name = "futures-util" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1812c7ab8aedf8d6f2701a43e1243acdbcc2b36ab26e2ad421eb99ac963d96d1" +checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" dependencies = [ "futures-channel", "futures-core", @@ -872,9 +872,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6cf41e31a7e7b78055b548826da45c7dc74e6a13a3fa6b897a17a01322f26" +checksum = "c4a1b21a2971cea49ca4613c0e9fe8225ecaf5de64090fddc6002284726e9244" dependencies = [ "console", "lazy_static", @@ -1030,9 +1030,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" dependencies = [ "scopeguard", ] @@ -1108,9 +1108,9 @@ checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" [[package]] name = "nb-connect" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670361df1bc2399ee1ff50406a0d422587dd3bb0da596e1978fe8e05dabddf4f" +checksum = "a19900e7eee95eb2b3c2e26d12a874cc80aaf750e31be6fcbe743ead369fa45d" dependencies = [ "libc", "socket2", @@ -1563,9 +1563,9 @@ dependencies = [ [[package]] name = "signal-hook" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a7f3f92a1da3d6b1d32245d0cbcbbab0cfc45996d8df619c42bccfa6d2bbb5f" +checksum = "ef33d6d0cd06e0840fba9985aab098c147e67e05cee14d412d3345ed14ff30ac" dependencies = [ "libc", "signal-hook-registry", @@ -1600,11 +1600,10 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.3.19" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" dependencies = [ - "cfg-if 1.0.0", "libc", "winapi", ] @@ -1842,9 +1841,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.13" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ "proc-macro2", "quote", @@ -2289,18 +2288,18 @@ checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" [[package]] name = "wast" -version = "35.0.0" +version = "35.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db5ae96da18bb5926341516fd409b5a8ce4e4714da7f0a1063d3b20ac9f9a1e1" +checksum = "2ef140f1b49946586078353a453a1d28ba90adfc54dde75710bc1931de204d68" dependencies = [ "leb128", ] [[package]] name = "wat" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" +checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ "wast", ] @@ -20,32 +20,4 @@ fn main() { clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir); - - // Clear Default Plugins and Layouts - - // Rerun on layout change - for entry in WalkDir::new("assets/layouts") { - let entry = entry.unwrap(); - println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); - } - - // Rerun on plugin change - #[cfg(not(feature = "publish"))] - let plugin_dir = "target"; - #[cfg(feature = "publish")] - let plugin_dir = "assets/plugins"; - for entry in WalkDir::new(plugin_dir) { - let entry = entry.unwrap(); - if entry.path().extension() == Some(OsStr::new("wasm")) { - println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); - } - } - - let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap(); - let data_dir = project_dirs.data_dir(); - drop(fs::remove_file(data_dir.join("plugins/status-bar.wasm"))); - drop(fs::remove_file(data_dir.join("plugins/tab-bar.wasm"))); - drop(fs::remove_file(data_dir.join("plugins/strider.wasm"))); - drop(fs::remove_file(data_dir.join("layouts/default.yaml"))); - drop(fs::remove_file(data_dir.join("layouts/strider.yaml"))); } diff --git a/src/cli.rs b/src/cli.rs index 41bf5f3a7..35d9ede11 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,7 @@ use std::path::PathBuf; use structopt::StructOpt; -#[derive(StructOpt, Debug, Default, Clone)] +#[derive(StructOpt, Default, Debug, Clone)] #[structopt(name = "zellij")] pub struct CliArgs { /// Send "split (direction h == horizontal / v == vertical)" to active zellij session @@ -31,7 +31,7 @@ pub struct CliArgs { pub debug: bool, } -#[derive(Debug, StructOpt)] +#[derive(Debug, StructOpt, Clone)] pub enum ConfigCli { /// Path to the configuration yaml file #[structopt(alias = "c")] diff --git a/src/client/mod.rs b/src/client/mod.rs index b6a0231a1..6ba6df737 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -9,12 +9,14 @@ use std::io::Write; use std::sync::mpsc; use std::thread; +use crate::cli::CliArgs; use crate::common::{ command_is_executing::CommandIsExecuting, errors::{ClientContext, ContextType}, + input::config::Config, input::handler::input_loop, os_input_output::ClientOsApi, - SenderType, SenderWithContext, SyncChannelWithContext, OPENCALLS, + SenderType, SenderWithContext, SyncChannelWithContext, }; use crate::server::ServerInstruction; @@ -29,7 +31,7 @@ pub enum ClientInstruction { Exit, } -pub fn start_client(mut os_input: Box<dyn ClientOsApi>) { +pub fn start_client(mut os_input: Box<dyn ClientOsApi>, opts: CliArgs) { let take_snapshot = "\u{1b}[?1049h"; os_input.unset_raw_mode(0); let _ = os_input @@ -37,17 +39,23 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>) { .write(take_snapshot.as_bytes()) .unwrap(); + let config = Config::from_cli_config(opts.config) + .map_err(|e| { + eprintln!("There was an error in the config file:\n{}", e); + std::process::exit(1); + }) + .unwrap(); + let mut command_is_executing = CommandIsExecuting::new(); let full_screen_ws = os_input.get_terminal_size_using_fd(0); os_input.set_raw_mode(0); - let err_ctx = OPENCALLS.with(|ctx| *ctx.borrow()); let (send_client_instructions, receive_client_instructions): SyncChannelWithContext< ClientInstruction, > = mpsc::sync_channel(500); - let mut send_client_instructions = - SenderWithContext::new(err_ctx, SenderType::SyncSender(send_client_instructions)); + let send_client_instructions = + SenderWithContext::new(SenderType::SyncSender(send_client_instructions)); os_input.connect_to_server(full_screen_ws); @@ -66,7 +74,14 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>) { let send_client_instructions = send_client_instructions.clone(); let command_is_executing = command_is_executing.clone(); let os_input = os_input.clone(); - move || input_loop(os_input, command_is_executing, send_client_instructions) + move || { + input_loop( + os_input, + config, + command_is_executing, + send_client_instructions, + ) + } }); let _signal_thread = thread::Builder::new() @@ -92,8 +107,7 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>) { let os_input = os_input.clone(); move || { loop { - let (instruction, err_ctx) = os_input.client_recv(); - send_client_instructions.update(err_ctx); + let (instruction, _err_ctx) = os_input.client_recv(); if let ClientInstruction::Exit = instruction { break; } @@ -122,7 +136,11 @@ pub fn start_client(mut os_input: Box<dyn ClientOsApi>) { let _ = os_input.send_to_server(ServerInstruction::ClientExit); os_input.unset_raw_mode(0); let goto_start_of_last_line = format!("\u{1b}[{};{}H", full_screen_ws.rows, 1); - let error = format!("{}\n{}", goto_start_of_last_line, backtrace); + let restore_snapshot = "\u{1b}[?1049l"; + let error = format!( + "{}\n{}{}", + goto_start_of_last_line, restore_snapshot, backtrace + ); let _ = os_input .get_stdout_writer() .write(error.as_bytes()) diff --git a/src/client/panes/terminal_pane.rs b/src/client/panes/terminal_pane.rs index 91db15caa..7bd592945 100644 --- a/src/client/panes/terminal_pane.rs +++ b/src/client/panes/terminal_pane.rs @@ -1,7 +1,6 @@ use crate::tab::Pane; use ::nix::pty::Winsize; use ::std::os::unix::io::RawFd; -use ::vte::Perform; use serde::{Deserialize, Serialize}; use std::fmt::Debug; diff --git a/src/client/tab.rs b/src/client/tab.rs index bdb22e2ca..1fdad6e2a 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -7,7 +7,7 @@ use crate::common::{input::handler::parse_keys, SenderWithContext}; use crate::layout::Layout; use crate::os_input_output::ServerOsApi; use crate::panes::{PaneId, PositionAndSize, TerminalPane}; -use crate::pty_bus::{PtyInstruction, VteEvent}; +use crate::pty_bus::{PtyInstruction, VteBytes}; use crate::server::ServerInstruction; use crate::utils::shared::adjust_to_size; use crate::wasm_vm::PluginInstruction; diff --git a/src/common/errors.rs b/src/common/errors.rs index 326729e87..bedc9d7f6 100644 --- a/src/common/errors.rs +++ b/src/common/errors.rs @@ -1,7 +1,7 @@ //! Error context system based on a thread-local representation of the call stack, itself based on //! the instructions that are sent between threads. -use super::{ServerInstruction, OPENCALLS}; +use super::{ServerInstruction, ASYNCOPENCALLS, OPENCALLS}; use crate::client::ClientInstruction; use crate::pty_bus::PtyInstruction; use crate::screen::ScreenInstruction; diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index e4a7b63c9..90df5b6a5 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -1,12 +1,14 @@ //! Main input logic. use super::actions::Action; -use super::keybinds::get_default_keybinds; +use super::keybinds::Keybinds; use crate::client::ClientInstruction; +use crate::common::input::config::Config; use crate::common::{SenderWithContext, OPENCALLS}; use crate::errors::ContextType; use crate::os_input_output::ClientOsApi; use crate::pty_bus::PtyInstruction; +use crate::screen::ScreenInstruction; use crate::server::ServerInstruction; use crate::CommandIsExecuting; @@ -19,8 +21,10 @@ struct InputHandler { /// The current input mode mode: InputMode, os_input: Box<dyn ClientOsApi>, + config: Config, command_is_executing: CommandIsExecuting, send_client_instructions: SenderWithContext<ClientInstruction>, + should_exit: bool, } impl InputHandler { @@ -28,6 +32,7 @@ impl InputHandler { fn new( os_input: Box<dyn ClientOsApi>, command_is_executing: CommandIsExecuting, + config: Config, send_client_instructions: SenderWithContext<ClientInstruction>, ) -> Self { InputHandler { @@ -36,6 +41,7 @@ impl InputHandler { config, command_is_executing, send_client_instructions, + should_exit: false, } } @@ -44,34 +50,26 @@ impl InputHandler { fn handle_input(&mut self) { let mut err_ctx = OPENCALLS.with(|ctx| *ctx.borrow()); err_ctx.add_call(ContextType::StdinHandler); - self.send_client_instructions.update(err_ctx); - self.os_input.update_senders(err_ctx); - if let Ok(keybinds) = get_default_keybinds() { - 'input_loop: loop { - //@@@ I think this should actually just iterate over stdin directly - let stdin_buffer = self.os_input.read_from_stdin(); - for key_result in stdin_buffer.events_and_raw() { - match key_result { - Ok((event, raw_bytes)) => match event { - termion::event::Event::Key(key) => { - let key = cast_termion_key(key); - // FIXME this explicit break is needed because the current test - // framework relies on it to not create dead threads that loop - // and eat up CPUs. Do not remove until the test framework has - // been revised. Sorry about this (@categorille) - let mut should_break = false; - for action in key_to_actions(&key, raw_bytes, &self.mode, &keybinds) - { - should_break |= self.dispatch_action(action); - } - if should_break { - break 'input_loop; - } - } - termion::event::Event::Mouse(_) - | termion::event::Event::Unsupported(_) => { - // Mouse and unsupported events aren't implemented yet, - // use a NoOp untill then. + let keybinds = self.config.keybinds.clone(); + let alt_left_bracket = vec![27, 91]; + loop { + if self.should_exit { + break; + } + let stdin_buffer = self.os_input.read_from_stdin(); + for key_result in stdin_buffer.events_and_raw() { + match key_result { + Ok((event, raw_bytes)) => match event { + termion::event::Event::Key(key) => { + let key = cast_termion_key(key); + self.handle_key(&key, raw_bytes, &keybinds); + } + termion::event::Event::Unsupported(unsupported_key) => { + // we have to do this because of a bug in termion + // this should be a key event and not an unsupported event + if unsupported_key == alt_left_bracket { + let key = Key::Alt('['); + self.handle_key(&key, raw_bytes, &keybinds); } } termion::event::Event::Mouse(_) => { @@ -138,8 +136,19 @@ impl InputHandler { }; self.os_input.send_to_server(screen_instr); } - Action::SwitchFocus(_) => { - self.os_input.send_to_server(ServerInstruction::MoveFocus); + Action::SwitchFocus => { + self.os_input + .send_to_server(ServerInstruction::ToScreen(ScreenInstruction::SwitchFocus)); + } + Action::FocusNextPane => { + self.os_input.send_to_server(ServerInstruction::ToScreen( + ScreenInstruction::FocusNextPane, + )); + } + Action::FocusPreviousPane => { + self.os_input.send_to_server(ServerInstruction::ToScreen( + ScreenInstruction::FocusPreviousPane, + )); } Action::MoveFocus(direction) => { let screen_instr = match direction { @@ -277,11 +286,17 @@ pub fn get_mode_info(mode: InputMode) -> ModeInfo { /// its [`InputHandler::handle_input()`] loop. pub fn input_loop( os_input: Box<dyn ClientOsApi>, + config: Config, command_is_executing: CommandIsExecuting, send_client_instructions: SenderWithContext<ClientInstruction>, ) { - let _handler = - InputHandler::new(os_input, command_is_executing, send_client_instructions).handle_input(); + let _handler = InputHandler::new( + os_input, + command_is_executing, + config, + send_client_instructions, + ) + .handle_input(); } pub fn parse_keys(input_bytes: &[u8]) -> Vec<Key> { diff --git a/src/common/mod.rs b/src/common/mod.rs index fb11538ed..28dcd5cc1 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -11,7 +11,8 @@ pub mod wasm_vm; use crate::panes::PaneId; use crate::server::ServerInstruction; -use errors::ErrorContext; +use async_std::task_local; +use errors::{get_current_ctx, ErrorContext}; use std::cell::RefCell; use std::sync::mpsc; @@ -43,8 +44,8 @@ pub struct SenderWithContext<T: Clone> { } impl<T: Clone> SenderWithContext<T> { - pub fn new(err_ctx: ErrorContext, sender: SenderType<T>) -> Self { - Self { err_ctx, sender } + pub fn new(sender: SenderType<T>) -> Self { + Self { sender } } /// Sends an event, along with the current [`ErrorContext`], on this @@ -66,3 +67,9 @@ thread_local!( /// stack in the form of an [`ErrorContext`]. pub static OPENCALLS: RefCell<ErrorContext> = RefCell::default() ); + +task_local! { + /// A key to some task local storage that holds a representation of the task's call + /// stack in the form of an [`ErrorContext`]. + static ASYNCOPENCALLS: RefCell<ErrorContext> = RefCell::default() +} diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 66957a4a1..3d7b8918c 100644 --- a/src/common/os_input_output.rs +++ b/ |