fixed bugs

1. scroll wasnt set to valid value after changing directory (i.e. after scrolling down, when switching to a directory with so few contents that scrolling is not required, it would display "[_] entries" but not show the first ones)
2. ScanFilesMode was reset on instance duplication
This commit is contained in:
Mark 2023-08-29 20:23:13 +02:00
parent aee0f4fb88
commit a2a6b9575a
2 changed files with 9 additions and 5 deletions

View File

@ -331,7 +331,7 @@ impl TuiFile {
last_drawn_files_count: self.last_drawn_files_count,
last_files_max_scroll: self.last_files_max_scroll,
after_rescanning_files: vec![],
scan_files_mode: ScanFilesMode::default(),
scan_files_mode: self.scan_files_mode.clone(),
}
}
pub fn new(current_dir: PathBuf) -> io::Result<Self> {

View File

@ -1,5 +1,5 @@
use crossterm::event::{poll, read, Event, KeyCode, KeyModifiers};
use crossterm::style::{Attribute, Color, Stylize};
use crossterm::style::{Attribute, Stylize};
use crossterm::{cursor, queue, style, terminal, ExecutableCommand};
use regex::RegexBuilder;
@ -11,7 +11,6 @@ use std::io::Write;
use std::os::unix::prelude::PermissionsExt;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use std::{fs, io};
@ -281,8 +280,13 @@ impl TuiFile {
}
if self.updates.rescanning_files_complete() {
self.updates.dont_rescanning_files_complete();
if self.current_index >= self.dir_content.len() {
self.current_index = self.dir_content.len().saturating_sub(1);
if self.current_index >= self.dir_content.len()
|| self.dir_content[self.current_index].passes_filter
{
self.set_current_index_to_visible(
self.dir_content.len().saturating_sub(1),
false,
);
}
if !self.after_rescanning_files.is_empty() {
for func in std::mem::replace(&mut self.after_rescanning_files, vec![]) {