Skip to content

Commit d19802c

Browse files
committed
bugfix: keep cursor inside the window
1 parent b91052b commit d19802c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zellij-sessionizer"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
description = "Zellij plugin to create sessions based on folder names"
66
license = "MIT"

src/dirlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ impl DirList {
3838
}
3939

4040
pub fn handle_down(&mut self) {
41-
if self.cursor < self.dirs.len().saturating_sub(1) {
41+
if self.cursor < self.filtered_dirs.len().saturating_sub(1) {
4242
self.cursor += 1;
4343
}
4444
}
4545

4646
pub fn get_selected(&self) -> Option<String> {
47-
if self.cursor < self.dirs.len() {
47+
if self.cursor < self.filtered_dirs.len() {
4848
Some(self.filtered_dirs[self.cursor].clone())
4949
} else {
5050
None

src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ impl ZellijPlugin for State {
130130

131131
fn render(&mut self, rows: usize, cols: usize) {
132132
println!();
133-
self.dirlist.render(rows.saturating_sub(5), cols);
134-
println!();
133+
self.dirlist.render(rows.saturating_sub(4), cols);
135134
println!();
136135
self.textinput.render(rows, cols);
137-
println!();
138-
println!("{}", self.debug);
136+
if !self.debug.is_empty() {
137+
println!();
138+
println!("{}", self.debug);
139+
}
139140
}
140141
}
141142

0 commit comments

Comments
 (0)