aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorwoojiq2023-08-29 07:00:55 +0000
committerGitHub2023-08-29 07:00:55 +0000
commitb67d2c3a68cf91cac6732a49a6737198717d3350 (patch)
tree8bec2d5bb2a47732c7d3f89519d3814d1c401d5a /helix-term
parent82cd44571569216bb18f37ee22965045574bdd1a (diff)
fix: line numbers remain relative when helix loses focus (#7955)
* fix: line numbers remain relative when helix loses focus If `line number = relative` and a new window is opened in helix, lines inside unfocused windows will be `absolute`. This commit adds the same thing when helix becomes unfocused in a terminal emulator. * partial rebase
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index aa159d40..0840749f 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -43,6 +43,8 @@ pub struct EditorView {
pub(crate) last_insert: (commands::MappableCommand, Vec<InsertEvent>),
pub(crate) completion: Option<Completion>,
spinners: ProgressSpinners,
+ /// Tracks if the terminal window is focused by reaction to terminal focus events
+ terminal_focused: bool,
}
#[derive(Debug, Clone)]
@@ -71,6 +73,7 @@ impl EditorView {
last_insert: (commands::MappableCommand::normal_mode, Vec::new()),
completion: None,
spinners: ProgressSpinners::default(),
+ terminal_focused: true,
}
}
@@ -171,7 +174,7 @@ impl EditorView {
view,
view.area,
theme,
- is_focused,
+ is_focused & self.terminal_focused,
&mut line_decorations,
);
}
@@ -1372,13 +1375,17 @@ impl Component for EditorView {
Event::Mouse(event) => self.handle_mouse_event(event, &mut cx),
Event::IdleTimeout => self.handle_idle_timeout(&mut cx),
- Event::FocusGained => EventResult::Ignored(None),
+ Event::FocusGained => {
+ self.terminal_focused = true;
+ EventResult::Consumed(None)
+ }
Event::FocusLost => {
if context.editor.config().auto_save {
if let Err(e) = commands::typed::write_all_impl(context, false, false) {
context.editor.set_error(format!("{}", e));
}
}
+ self.terminal_focused = false;
EventResult::Consumed(None)
}
}