(&mut self)
| 219 | } |
| 220 | |
| 221 | pub(crate) fn decrease_selected_lines_indentation(&mut self) { |
| 222 | if !self.selection.is_selected { |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | let selection = self.get_sorted_selection_points().unwrap(); |
| 227 | let backup_cursor = self.cursor.clone(); |
| 228 | let mut should_adjust_selection_start = false; |
| 229 | let mut should_adjust_selection_end = false; |
| 230 | |
| 231 | self.cursor = self.selection.start_point.clone(); |
| 232 | if !self.is_current_line_empty() && self.lines[self.cursor.row][0].character == ' ' { |
| 233 | should_adjust_selection_start = true; |
| 234 | } |
| 235 | self.cursor = self.selection.end_point.clone(); |
| 236 | if !self.is_current_line_empty() && self.lines[self.cursor.row][0].character == ' ' { |
| 237 | should_adjust_selection_end = true; |
| 238 | } |
| 239 | |
| 240 | self.cursor = selection.start_point.clone(); |
| 241 | |
| 242 | for _ in selection.start_point.row..=selection.end_point.row { |
| 243 | self.decrease_current_line_indentation(); |
| 244 | self.move_cursor_down(); |
| 245 | } |
| 246 | |
| 247 | self.cursor = backup_cursor; |
| 248 | |
| 249 | if self.cursor.col >= self.settings.tab_width && should_adjust_selection_start{ |
| 250 | self.cursor.col -= self.settings.tab_width; |
| 251 | } else if should_adjust_selection_start { |
| 252 | self.cursor.col = 0; |
| 253 | } |
| 254 | |
| 255 | if self.selection.start_point.col >= self.settings.tab_width |
| 256 | && should_adjust_selection_start { |
| 257 | self.selection.start_point.col -= self.settings.tab_width; |
| 258 | } else if should_adjust_selection_start { |
| 259 | self.selection.start_point.col = 0; |
| 260 | } |
| 261 | |
| 262 | if self.selection.end_point.col >= self.settings.tab_width |
| 263 | && should_adjust_selection_end { |
| 264 | self.selection.end_point.col -= self.settings.tab_width; |
| 265 | } else if should_adjust_selection_end { |
| 266 | self.selection.end_point.col = 0; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | pub(crate) fn decrease_current_line_indentation(&mut self) { |
| 271 | if self.is_current_line_empty() { |
no test coverage detected