Skip to content

Commit

Permalink
Tiny change
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltrt committed Aug 22, 2024
1 parent a5b64f0 commit 11ef557
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/models/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ impl Match {
self.get_associated_leading_empty_lines(node, code);
}

fn get_associated_leading_empty_lines(&mut self, matched_node: &Node, code: &String) -> () {

fn get_associated_leading_empty_lines(&mut self, matched_node: &Node, code: &String) {
if let Some(empty_range) = self.find_empty_line_range(code, matched_node) {
let skipped_range = Range {
start_byte: empty_range.start,
Expand Down Expand Up @@ -157,13 +156,13 @@ impl Match {
break;
}
}

if found {
// Get the previous sibling node's end byte if it exists, in order to prevent overdeletions
let prev_sibling_end_byte = if let Some(prev_sibling) = node.prev_sibling() {
prev_sibling.end_byte()
prev_sibling.end_byte()
} else {
0
0
};
let max_end_byte = std::cmp::max(end_byte, prev_sibling_end_byte);
Some(max_end_byte..node.start_byte())
Expand Down
4 changes: 1 addition & 3 deletions src/models/unit_tests/source_code_unit_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tree_sitter::Parser;
use crate::{
filter,
models::{
default_configs::{JAVA, RUBY,SWIFT, UNUSED_CODE_PATH},
default_configs::{JAVA, RUBY, SWIFT, UNUSED_CODE_PATH},
filter::Filter,
language::PiranhaLanguage,
matches::{Point, Range},
Expand Down Expand Up @@ -774,8 +774,6 @@ fn test_removes_blank_lines_after_inline_cleanup() {
);
}



#[test]
fn test_switch_entry_blank_lines() {
let inline_cleanup_rule = piranha_rule! {
Expand Down

0 comments on commit 11ef557

Please sign in to comment.