Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mouse configuration not getting updated after config-reload and set-option (#5648) #5931

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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