Skip to content
Merged
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
14 changes: 12 additions & 2 deletions src/active_suggestions.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::bash_funcs;
use crate::content_utils::{
ansi_string_to_spans, highlight_matching_indices, middle_truncate_spans, style_for_path,
take_prefix_of_spans, ts_to_timeago_string_5chars, vec_spans_width,
};
use crate::palette::Palette;
use crate::stateful_sliding_window::StatefulSlidingWindow;
use crate::text_buffer::{SubString, TextBuffer};
use crate::{bash_funcs, tab_completion_context};
use itertools::Itertools;
use ratatui::prelude::*;
use skim::fuzzy_matcher::FuzzyMatcher;
Expand Down Expand Up @@ -653,6 +653,7 @@ pub struct ActiveSuggestionsBuilder {
pub unprocessed: VecDeque<UnprocessedSuggestion>,
pub auto_accept_if_solo: bool,
pub common_prefix: Option<String>,
pub comp_type: tab_completion_context::CompType,
}

impl ActiveSuggestionsBuilder {
Expand All @@ -664,6 +665,7 @@ impl ActiveSuggestionsBuilder {
unprocessed: VecDeque::new(),
auto_accept_if_solo: true,
common_prefix: None,
comp_type: tab_completion_context::CompType::default(),
}
}

Expand All @@ -675,6 +677,11 @@ impl ActiveSuggestionsBuilder {
self
}

pub fn with_comp_type(mut self, comp_type: tab_completion_context::CompType) -> Self {
self.comp_type = comp_type;
self
}

/// Append a single already-processed suggestion.
#[allow(dead_code)]
pub fn push_processed(&mut self, sug: ProcessedSuggestion) {
Expand Down Expand Up @@ -811,6 +818,7 @@ pub struct ActiveSuggestions {
fuzzy_matcher: ArinaeMatcher,
/// How long it took to generate the completions.
pub load_time: std::time::Duration,
pub comp_type: tab_completion_context::CompType,
}

impl ActiveSuggestions {
Expand All @@ -824,6 +832,7 @@ impl ActiveSuggestions {
unprocessed: unprocessed_suggestions,
common_prefix: _,
auto_accept_if_solo: _,
comp_type,
} = builder;
let sug_len = processed_suggestions.len() + unprocessed_suggestions.len();

Expand All @@ -841,6 +850,7 @@ impl ActiveSuggestions {
col_window_to_show: StatefulSlidingWindow::new(0, 1, sug_len, Some(1)),
fuzzy_matcher: ArinaeMatcher::new(skim::CaseMatching::Smart, true),
load_time,
comp_type,
};

active_sug.update_fuzzy_filtered();
Expand Down Expand Up @@ -880,7 +890,7 @@ impl ActiveSuggestions {
}

/// Return the flat (1-D) index of the currently-selected suggestion.
fn current_1d_index(&self) -> usize {
pub fn current_1d_index(&self) -> usize {
self.selected_col
.saturating_mul(self.last_num_rows_per_col)
.saturating_add(self.selected_row)
Expand Down
15 changes: 12 additions & 3 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2129,14 +2129,23 @@ impl<'a> App<'a> {
}
}

let pos_string = if active_suggestions.last_num_data_cols > 1 {
format!(
"({}, {})",
active_suggestions.selected_col, active_suggestions.selected_row
)
} else {
format!("{}", active_suggestions.current_1d_index())
};

content.write_tagged_span(&TaggedSpan::new(
Span::styled(
format!(
"# Pos: ({}, {}); Filtered {}/{} [{}ms]",
active_suggestions.selected_col,
active_suggestions.selected_row,
"# Pos: {}; Filtered: {}/{}; {} ({}ms)",
pos_string,
active_suggestions.filtered_suggestions_len(),
active_suggestions.all_suggestions_len(),
active_suggestions.comp_type.display_name(),
active_suggestions.load_time.as_millis(),
),
self.settings.colour_palette.secondary_text(),
Expand Down
Loading
Loading