File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -136,13 +136,22 @@ impl Data {
136
136
}
137
137
}
138
138
139
+ /// If the points are not filtered returns the input otherwise translates it from the filtered array
140
+ fn get_real_index ( & self , index : usize ) -> usize {
141
+ if let Some ( filtered) = self . filtered_rows . as_ref ( ) {
142
+ filtered[ index]
143
+ } else {
144
+ index
145
+ }
146
+ }
147
+
139
148
pub fn selected_row_data_as_slice (
140
149
& mut self ,
141
150
common_fields : & BTreeSet < String > ,
142
151
) -> Option < & [ ( String , String ) ] > {
143
152
let selected_row_index = self . selected_row ?;
144
- // TODO 1: Fix here to use appropriate list
145
- Some ( self . rows [ selected_row_index ] . as_slice ( common_fields) )
153
+ let real_index = self . get_real_index ( selected_row_index ) ;
154
+ Some ( self . rows [ real_index ] . as_slice ( common_fields) )
146
155
}
147
156
148
157
pub fn move_selected_to_next ( & mut self ) {
Original file line number Diff line number Diff line change @@ -16,22 +16,12 @@ impl<'a> Iterator for DataIter<'a> {
16
16
type Item = & ' a LogRow ;
17
17
18
18
fn next ( & mut self ) -> Option < Self :: Item > {
19
- let result = match self . data . filtered_rows . as_ref ( ) {
20
- Some ( filtered) => {
21
- if self . pos >= filtered. len ( ) {
22
- return None ;
23
- }
24
- Some ( & self . data . rows [ filtered[ self . pos ] ] )
25
- }
26
- None => {
27
- if self . pos >= self . data . rows . len ( ) {
28
- return None ;
29
- }
30
- Some ( & self . data . rows [ self . pos ] )
31
- }
32
- } ;
19
+ if self . pos >= self . data . len ( ) {
20
+ return None ;
21
+ }
22
+ let real_index = self . data . get_real_index ( self . pos ) ;
33
23
self . pos += 1 ;
34
- result
24
+ Some ( & self . data . rows [ real_index ] )
35
25
}
36
26
37
27
fn nth ( & mut self , n : usize ) -> Option < Self :: Item > {
You can’t perform that action at this time.
0 commit comments