Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Dec 24, 2024
1 parent 096d5ba commit f20bc9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
12 changes: 0 additions & 12 deletions crates/maple_core/src/previewer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,7 @@ pub fn preview_file<P: AsRef<Path>>(

let abs_path = as_absolute_path(path.as_ref())?;

let now = std::time::Instant::now();
tracing::info!("=============== Reading determine_file_size_tier");
let file_size = utils::io::determine_file_size_tier(path.as_ref())?;
tracing::info!(
"=============== determine_file_size_tier elapsed: {}ms, file_size_tier: {file_size:?}",
now.elapsed().as_millis()
);

let lines = match file_size {
FileSizeTier::Empty | FileSizeTier::Small => {
Expand Down Expand Up @@ -191,13 +185,7 @@ pub fn preview_file_with_truncated_title<P: AsRef<Path>>(

let truncated_abs_path = truncate_absolute_path(&abs_path, max_title_width).into_owned();

let now = std::time::Instant::now();
tracing::info!("=============== Reading determine_file_size_tier truncated");
let file_size = utils::io::determine_file_size_tier(path.as_ref())?;
tracing::info!(
"=============== determine_file_size_tier elapsed: {}ms, file_size_tier: {file_size:?}",
now.elapsed().as_millis()
);

let lines = match file_size {
FileSizeTier::Empty | FileSizeTier::Small => {
Expand Down
20 changes: 10 additions & 10 deletions crates/maple_core/src/stdio_server/provider/hooks/on_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ impl<'a> CachedPreviewImpl<'a> {
}
};

if file_size.is_empty() {
let mut lines = lines;
lines.push("<Empty file>".to_string());
return Ok(Preview::new_file_preview(
lines,
None,
VimSyntaxInfo::fname(fname),
));
}

let highlight_source = if file_size.is_small() {
SyntaxHighlighter {
lines: lines.clone(),
Expand All @@ -495,16 +505,6 @@ impl<'a> CachedPreviewImpl<'a> {
None
};

if file_size.is_empty() {
let mut lines = lines;
lines.push("<Empty file>".to_string());
return Ok(Preview::new_file_preview(
lines,
scrollbar,
VimSyntaxInfo::fname(fname),
));
}

let mut preview = Preview::new_file_preview(lines, scrollbar, VimSyntaxInfo::default());
preview.set_highlights(highlight_source, path);

Expand Down

0 comments on commit f20bc9c

Please sign in to comment.