Skip to content

Commit

Permalink
Refactor as raw_headers method
Browse files Browse the repository at this point in the history
  • Loading branch information
YS-L committed Feb 24, 2024
1 parent 6d30ba7 commit b7d1e63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ impl App {
if should_create_new_sorter {
let column_name = self
.rows_view
.get_column_name_global(selected_column_index as usize);
.raw_headers()
.get(selected_column_index as usize)
.cloned()
.unwrap_or_default();
let _sorter = sort::Sorter::new(
self.shared_config.clone(),
selected_column_index as usize,
Expand Down
12 changes: 4 additions & 8 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ impl RowsView {
&self.headers
}

pub fn raw_headers(&self) -> &Vec<String> {
&self.reader.headers
}

pub fn rows(&self) -> &Vec<Row> {
&self.rows
}
Expand Down Expand Up @@ -402,14 +406,6 @@ impl RowsView {
self.headers[column_index].origin_index
}

pub fn get_column_name_global(&self, global_column_index: usize) -> String {
self.reader
.headers
.get(global_column_index)
.cloned()
.unwrap_or_default()
}

fn get_default_headers_from_reader(reader: &CsvLensReader) -> Vec<Header> {
reader
.headers
Expand Down

0 comments on commit b7d1e63

Please sign in to comment.