Skip to content

Commit 24493cf

Browse files
committed
fixes
1 parent f9f50cc commit 24493cf

File tree

2 files changed

+14
-3
lines changed
  • crates
    • pg_statement_splitter/src
    • pg_workspace_new/src/workspace/server

2 files changed

+14
-3
lines changed

crates/pg_statement_splitter/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ mod tests {
5656
assert_eq!(*expected, self.input[*range].to_string());
5757
}
5858

59+
assert!(
60+
self.parse.ranges.is_sorted_by_key(|r| r.start()),
61+
"Ranges are not sorted"
62+
);
63+
5964
self
6065
}
6166

crates/pg_workspace_new/src/workspace/server/change.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ impl StatementChange {
4141
}
4242
}
4343

44+
/// Returns all relevant details about the change and its effects on the current state of the document.
4445
struct Affected {
46+
/// Full range of the change, including the range of all statements that intersect with the change
4547
affected_range: TextRange,
48+
/// All indices of affected statement positions
4649
affected_indices: Vec<usize>,
50+
/// The index of the first statement position before the change, if any
4751
prev_index: Option<usize>,
52+
/// The index of the first statement position after the change, if any
4853
next_index: Option<usize>,
54+
/// the full affected range includng the prev and next statement
4955
full_affected_range: TextRange,
5056
}
5157

@@ -79,11 +85,11 @@ impl Document {
7985
changes.extend(
8086
pg_statement_splitter::split(&self.content)
8187
.ranges
82-
.iter()
88+
.into_iter()
8389
.map(|range| {
8490
let id = self.id_generator.next();
85-
let text = self.content[*range].to_string();
86-
self.positions.push((id, *range));
91+
let text = self.content[range].to_string();
92+
self.positions.push((id, range));
8793

8894
StatementChange::Added(AddedStatement {
8995
stmt: Statement {

0 commit comments

Comments
 (0)