on master help sign in
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

commitb67d2c3a68cf91cac6732a49a6737198717d3350 authorwoojiq <122799969+woojiq@users.noreply.github.com> dateTue 29 Aug 2023, 10:00 (3 years ago) parent82cd445
1 file changed+9−2
helix-term/src/ui/editor.rs+9−2
helix-term/src/ui/editor.rs+9−2
@@ -43,6 +43,8 @@ pub struct EditorView {
4343 pub(crate) last_insert: (commands::MappableCommand, Vec<InsertEvent>),
4444 pub(crate) completion: Option<Completion>,
4545 spinners: ProgressSpinners,
46+ /// Tracks if the terminal window is focused by reaction to terminal focus events
47+ terminal_focused: bool,
4648}
4749
4850#[derive(Debug, Clone)]
@@ -71,6 +73,7 @@ impl EditorView {
7173 last_insert: (commands::MappableCommand::normal_mode, Vec::new()),
7274 completion: None,
7375 spinners: ProgressSpinners::default(),
76+ terminal_focused: true,
7477 }
7578 }
7679
@@ -171,7 +174,7 @@ impl EditorView {
171174 view,
172175 view.area,
173176 theme,
174− is_focused,
177+ is_focused & self.terminal_focused,
175178 &mut line_decorations,
176179 );
177180 }
@@ -1372,13 +1375,17 @@ impl Component for EditorView {
13721375
13731376 Event::Mouse(event) => self.handle_mouse_event(event, &mut cx),
13741377 Event::IdleTimeout => self.handle_idle_timeout(&mut cx),
1375− Event::FocusGained => EventResult::Ignored(None),
1378+ Event::FocusGained => {
1379+ self.terminal_focused = true;
1380+ EventResult::Consumed(None)
1381+ }
13761382 Event::FocusLost => {
13771383 if context.editor.config().auto_save {
13781384 if let Err(e) = commands::typed::write_all_impl(context, false, false) {
13791385 context.editor.set_error(format!("{}", e));
13801386 }
13811387 }
1388+ self.terminal_focused = false;
13821389 EventResult::Consumed(None)
13831390 }
13841391 }