improve popup ordering

This commit is contained in:
alice pellerin
2026-04-10 20:44:40 -05:00
parent a091b504fb
commit 3503e35c6e
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -1,4 +1,5 @@
use std::{cmp::min, collections::hash_set::Entry, convert::identity, fs::File, io::Write, iter, mem::{replace, swap}}; use std::{cmp::min, collections::hash_set::Entry, convert::identity, fs::File, io::Write, iter, mem::{replace, swap}};
use itertools::Itertools;
use ratatui::{style::{Color, Stylize}, text::Span}; use ratatui::{style::{Color, Stylize}, text::Span};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{BYTES_OF_PADDING, BYTES_PER_LINE, LINES_OF_PADDING, app::WindowSize, buffer::{Buffer, InspectionStatus, Mode, PartialAction, Popup}, cursor::Cursor, edit_action::EditAction}; use crate::{BYTES_OF_PADDING, BYTES_PER_LINE, LINES_OF_PADDING, app::WindowSize, buffer::{Buffer, InspectionStatus, Mode, PartialAction, Popup}, cursor::Cursor, edit_action::EditAction};
@@ -1207,6 +1208,7 @@ impl Buffer {
Some(Popup::new(cursor.lower_bound(), popup_lines)) Some(Popup::new(cursor.lower_bound(), popup_lines))
} }
}) })
.sorted_unstable_by_key(|popup| popup.at)
); );
if self.popups.is_empty() { if self.popups.is_empty() {
@@ -1236,6 +1238,7 @@ impl Buffer {
Some(Popup::new(cursor.lower_bound(), popup_lines)) Some(Popup::new(cursor.lower_bound(), popup_lines))
} }
}) })
.sorted_unstable_by_key(|popup| popup.at)
); );
if self.popups.is_empty() { if self.popups.is_empty() {
+2 -2
View File
@@ -53,7 +53,7 @@ pub enum PartialAction {
#[derive(Clone)] #[derive(Clone)]
pub struct Popup { pub struct Popup {
at: usize, pub at: usize,
width: u16, width: u16,
primary: bool, primary: bool,
lines: Vec<Span<'static>> lines: Vec<Span<'static>>
@@ -310,7 +310,7 @@ impl Buffer {
}, },
} }
if !action.is_inspection() { if action.clears_popups() && !action.is_inspection() {
self.inspection_status = None; self.inspection_status = None;
} }
} }