-
Notifications
You must be signed in to change notification settings - Fork 17
Fix ranges of comment sections #855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -571,3 +571,22 @@ pub(crate) fn node_find_containing_call<'tree>(node: Node<'tree>) -> Option<Node | |
|
||
None | ||
} | ||
|
||
pub(crate) fn point_end_of_previous_row( | ||
mut point: tree_sitter::Point, | ||
contents: &ropey::Rope, | ||
) -> tree_sitter::Point { | ||
if point.row > 0 { | ||
let prev_row = point.row - 1; | ||
let line = contents.line(prev_row as usize); | ||
let line_len = line.len_chars().saturating_sub(1); // Subtract 1 for newline | ||
tree_sitter::Point { | ||
row: prev_row, | ||
column: line_len, | ||
} | ||
Comment on lines
+582
to
+586
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason you don't include the newline? I feel like the newline is technically just the end of the current line, right? So it feels like that position would be valid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because after the newline you are no longer on that line, so that position actually represents column 0 of the line we started with. The n + 1 position on the line doesn't really exist in fact. Side note, I find it confusing that Rope's line iterator includes trailing newlines. I think a "split by line" viewpoint is more intuitive. |
||
} else { | ||
// We're at the very beginning of the document, can't go back further | ||
point.column = 0; | ||
point | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.