Skip to content

Commit

Permalink
Fix mouse configuration not getting updated after config-reload and s…
Browse files Browse the repository at this point in the history
…et-option (#5648)
  • Loading branch information
johnfrankmorgan committed Feb 12, 2023
1 parent 3b301a9 commit 85b8ffc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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()
Expand Down

0 comments on commit 85b8ffc

Please sign in to comment.