Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ impl Completion {

let popup = Popup::new(Self::ID, menu)
.with_scrollbar(false)
.ignore_escape_key(true);
.ignore_escape_key(true)
.sticky(false);

let (view, doc) = current_ref!(editor);
let text = doc.text().slice(..);
Expand Down
21 changes: 16 additions & 5 deletions helix-term/src/ui/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct Popup<T: Component> {
ignore_escape_key: bool,
id: &'static str,
has_scrollbar: bool,
sticky: bool,
}

impl<T: Component> Popup<T> {
Expand All @@ -53,6 +54,7 @@ impl<T: Component> Popup<T> {
ignore_escape_key: false,
id,
has_scrollbar: true,
sticky: true,
}
}

Expand Down Expand Up @@ -111,6 +113,11 @@ impl<T: Component> Popup<T> {
self
}

pub fn sticky(mut self, sticky: bool) -> Self {
self.sticky = sticky;
self
}

pub fn contents(&self) -> &T {
&self.contents
}
Expand All @@ -125,11 +132,15 @@ impl<T: Component> Popup<T> {

fn render_info(&mut self, viewport: Rect, editor: &Editor) -> RenderInfo {
let mut position = editor.cursor().0.unwrap_or_default();
if let Some(old_position) = self
.position
.filter(|old_position| old_position.row == position.row)
{
position = old_position;
if self.sticky {
if let Some(old_position) = self
.position
.filter(|old_position| old_position.row == position.row)
{
position = old_position;
} else {
self.position = Some(position);
}
} else {
self.position = Some(position);
}
Expand Down