From 85b8ffc71177ac0e3c0f53c96337c608483465bd Mon Sep 17 00:00:00 2001 From: johnfrankmorgan Date: Sat, 11 Feb 2023 23:08:57 +0000 Subject: [PATCH] Fix mouse configuration not getting updated after config-reload and set-option (#5648) --- helix-term/src/application.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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()