|
25 | 25 |
|
26 | 26 | if cursor_inbetween_nodes(tree, params.position)
|
27 | 27 | || cursor_prepared_to_write_token_after_last_node(tree, params.position)
|
| 28 | + || cursor_before_semicolon(tree, params.position) |
28 | 29 | {
|
29 | 30 | Ok(SanitizedCompletionParams::with_adjusted_sql(params))
|
30 | 31 | } else {
|
@@ -134,7 +135,7 @@ fn cursor_prepared_to_write_token_after_last_node(
|
134 | 135 | cursor_pos == tree.root_node().end_byte() + 1
|
135 | 136 | }
|
136 | 137 |
|
137 |
| -fn cursor_before_or_on_semicolon(tree: &tree_sitter::Tree, position: TextSize) -> bool { |
| 138 | +fn cursor_before_semicolon(tree: &tree_sitter::Tree, position: TextSize) -> bool { |
138 | 139 | let mut cursor = tree.walk();
|
139 | 140 | let mut leaf_node = tree.root_node();
|
140 | 141 |
|
@@ -183,7 +184,7 @@ mod tests {
|
183 | 184 | use pgt_text_size::TextSize;
|
184 | 185 |
|
185 | 186 | use crate::sanitization::{
|
186 |
| - cursor_before_or_on_semicolon, cursor_inbetween_nodes, |
| 187 | + cursor_before_semicolon, cursor_inbetween_nodes, |
187 | 188 | cursor_prepared_to_write_token_after_last_node,
|
188 | 189 | };
|
189 | 190 |
|
@@ -262,23 +263,23 @@ mod tests {
|
262 | 263 | let mut tree = parser.parse(input.to_string(), None).unwrap();
|
263 | 264 |
|
264 | 265 | // select * from ;| <-- it's after the statement
|
265 |
| - assert!(!cursor_before_or_on_semicolon(&mut tree, TextSize::new(19))); |
| 266 | + assert!(!cursor_before_semicolon(&mut tree, TextSize::new(19))); |
266 | 267 |
|
267 | 268 | // select * from| ; <-- still touches the from
|
268 |
| - assert!(!cursor_before_or_on_semicolon(&mut tree, TextSize::new(13))); |
| 269 | + assert!(!cursor_before_semicolon(&mut tree, TextSize::new(13))); |
269 | 270 |
|
270 | 271 | // not okay to be ON the semi.
|
271 | 272 | // select * from |;
|
272 |
| - assert!(!cursor_before_or_on_semicolon(&mut tree, TextSize::new(18))); |
| 273 | + assert!(!cursor_before_semicolon(&mut tree, TextSize::new(18))); |
273 | 274 |
|
274 | 275 | // anything is fine here
|
275 | 276 | // select * from | ;
|
276 | 277 | // select * from | ;
|
277 | 278 | // select * from | ;
|
278 | 279 | // select * from |;
|
279 |
| - assert!(cursor_before_or_on_semicolon(&mut tree, TextSize::new(14))); |
280 |
| - assert!(cursor_before_or_on_semicolon(&mut tree, TextSize::new(15))); |
281 |
| - assert!(cursor_before_or_on_semicolon(&mut tree, TextSize::new(16))); |
282 |
| - assert!(cursor_before_or_on_semicolon(&mut tree, TextSize::new(17))); |
| 280 | + assert!(cursor_before_semicolon(&mut tree, TextSize::new(14))); |
| 281 | + assert!(cursor_before_semicolon(&mut tree, TextSize::new(15))); |
| 282 | + assert!(cursor_before_semicolon(&mut tree, TextSize::new(16))); |
| 283 | + assert!(cursor_before_semicolon(&mut tree, TextSize::new(17))); |
283 | 284 | }
|
284 | 285 | }
|
0 commit comments