diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index a1685fcfa956..55b743d1fc16 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -394,6 +394,13 @@ impl Application { // the configuration. self.editor.refresh_config(); + match self.refresh_mouse(self.config.load().editor.mouse) { + Ok(_) => {} + Err(err) => { + self.editor.set_error(err.to_string()); + } + } + // reset view position in case softwrap was enabled/disabled let scrolloff = self.editor.config().scrolloff; for (view, _) in self.editor.tree.views_mut() { @@ -402,6 +409,17 @@ impl Application { } } + /// refresh mouse state after config change + fn refresh_mouse(&self, enabled: bool) -> Result<(), Error> { + if enabled { + execute!(stdout(), EnableMouseCapture) + .map_err(|err| anyhow::anyhow!("Failed to enable mouse: {}", err)) + } else { + execute!(stdout(), DisableMouseCapture) + .map_err(|err| anyhow::anyhow!("Failed to disable mouse: {}", err)) + } + } + /// refresh language config after config change fn refresh_language_config(&mut self) -> Result<(), Error> { let syntax_config = helix_core::config::user_syntax_loader()