1use crate::utils::element_cache::ElementCache;
4use std::collections::HashSet;
5use std::ops::Range;
6
7fn find_char_boundary(s: &str, byte_idx: usize) -> usize {
14 if byte_idx >= s.len() {
15 return s.len();
16 }
17
18 if s.is_char_boundary(byte_idx) {
20 return byte_idx;
21 }
22
23 let mut pos = byte_idx;
26 while pos > 0 && !s.is_char_boundary(pos) {
27 pos -= 1;
28 }
29 pos
30}
31
32fn byte_to_char_count(s: &str, byte_idx: usize) -> usize {
35 let safe_byte_idx = find_char_boundary(s, byte_idx);
36 s[..safe_byte_idx].chars().count() + 1 }
38
39#[derive(Debug)]
40pub struct LineIndex<'a> {
41 line_starts: Vec<usize>,
42 content: &'a str,
43 code_block_lines: Option<HashSet<usize>>,
44}
45
46impl<'a> LineIndex<'a> {
47 pub fn new(content: &'a str) -> Self {
48 let mut line_starts = vec![0];
49 let mut pos = 0;
50
51 for c in content.chars() {
52 pos += c.len_utf8();
53 if c == '\n' {
54 line_starts.push(pos);
55 }
56 }
57
58 let mut index = Self {
59 line_starts,
60 content,
61 code_block_lines: None,
62 };
63
64 index.compute_code_block_lines();
66
67 index
68 }
69
70 pub fn with_line_starts(content: &'a str, line_starts: Vec<usize>) -> Self {
74 let mut index = Self {
75 line_starts,
76 content,
77 code_block_lines: None,
78 };
79
80 index.compute_code_block_lines();
82
83 index
84 }
85
86 pub fn with_line_starts_and_code_blocks(
91 content: &'a str,
92 line_starts: Vec<usize>,
93 code_block_byte_ranges: &[(usize, usize)],
94 ) -> Self {
95 let mut code_block_lines = HashSet::new();
96
97 for &(block_start, block_end) in code_block_byte_ranges {
98 let start_line = match line_starts.binary_search(&block_start) {
99 Ok(idx) => idx,
100 Err(idx) => idx.saturating_sub(1),
101 };
102 let end_line = if block_end == 0 {
103 0
104 } else {
105 match line_starts.binary_search(&block_end) {
106 Ok(idx) => idx.saturating_sub(1),
108 Err(idx) => idx.saturating_sub(1),
109 }
110 };
111 for line_idx in start_line..=end_line {
112 code_block_lines.insert(line_idx);
113 }
114 }
115
116 Self {
117 line_starts,
118 content,
119 code_block_lines: Some(code_block_lines),
120 }
121 }
122
123 fn get_line(&self, line_idx: usize) -> Option<&'a str> {
126 let start = *self.line_starts.get(line_idx)?;
127 let end = self
128 .line_starts
129 .get(line_idx + 1)
130 .copied()
131 .unwrap_or(self.content.len());
132 let line = &self.content[start..end];
133 let line = line.strip_suffix('\n').unwrap_or(line);
135 let line = line.strip_suffix('\r').unwrap_or(line);
136 Some(line)
137 }
138
139 pub fn line_col_to_byte_range(&self, line: usize, column: usize) -> Range<usize> {
140 let line = line.saturating_sub(1);
141 let line_start = *self.line_starts.get(line).unwrap_or(&self.content.len());
142
143 let current_line = self.get_line(line).unwrap_or("");
144 let char_col = column.saturating_sub(1);
146 let char_count = current_line.chars().count();
147 let safe_char_col = char_col.min(char_count);
148
149 let byte_offset = current_line
151 .char_indices()
152 .nth(safe_char_col)
153 .map(|(idx, _)| idx)
154 .unwrap_or(current_line.len());
155
156 let start = line_start + byte_offset;
157 start..start
158 }
159
160 pub fn line_col_to_byte_range_with_length(&self, line: usize, column: usize, length: usize) -> Range<usize> {
167 let line = line.saturating_sub(1);
168 let line_start = *self.line_starts.get(line).unwrap_or(&self.content.len());
169 let line_end = self.line_starts.get(line + 1).copied().unwrap_or(self.content.len());
170 let mut current_line = &self.content[line_start..line_end];
171 if let Some(stripped) = current_line.strip_suffix('\n') {
172 current_line = stripped.strip_suffix('\r').unwrap_or(stripped);
173 }
174 if current_line.is_ascii() {
175 let line_len = current_line.len();
176 let start_byte = column.saturating_sub(1).min(line_len);
177 let end_byte = start_byte.saturating_add(length).min(line_len);
178 let start = line_start + start_byte;
179 let end = line_start + end_byte;
180 return start..end;
181 }
182 let char_col = column.saturating_sub(1);
184 let char_count = current_line.chars().count();
185 let safe_char_col = char_col.min(char_count);
186
187 let mut char_indices = current_line.char_indices();
189 let start_byte = char_indices
190 .nth(safe_char_col)
191 .map(|(idx, _)| idx)
192 .unwrap_or(current_line.len());
193
194 let end_char_col = (safe_char_col + length).min(char_count);
196 let end_byte = current_line
197 .char_indices()
198 .nth(end_char_col)
199 .map(|(idx, _)| idx)
200 .unwrap_or(current_line.len());
201
202 let start = line_start + start_byte;
203 let end = line_start + end_byte;
204 start..end
205 }
206
207 pub fn whole_line_range(&self, line: usize) -> Range<usize> {
210 let line_idx = line.saturating_sub(1);
211 let start = *self.line_starts.get(line_idx).unwrap_or(&self.content.len());
212 let end = self
213 .line_starts
214 .get(line_idx + 1)
215 .copied()
216 .unwrap_or(self.content.len());
217 start..end
218 }
219
220 pub fn multi_line_range(&self, start_line: usize, end_line: usize) -> Range<usize> {
223 let start_idx = start_line.saturating_sub(1);
224 let end_idx = end_line.saturating_sub(1);
225
226 let start = *self.line_starts.get(start_idx).unwrap_or(&self.content.len());
227 let end = self.line_starts.get(end_idx + 1).copied().unwrap_or(self.content.len());
228 start..end
229 }
230
231 pub fn line_text_range(&self, line: usize, start_col: usize, end_col: usize) -> Range<usize> {
238 let line_idx = line.saturating_sub(1);
239 let line_start = *self.line_starts.get(line_idx).unwrap_or(&self.content.len());
240
241 let current_line = self.get_line(line_idx).unwrap_or("");
243 let char_count = current_line.chars().count();
244
245 let start_char_col = start_col.saturating_sub(1).min(char_count);
247 let end_char_col = end_col.saturating_sub(1).min(char_count);
248
249 let mut char_indices = current_line.char_indices();
250 let start_byte = char_indices
251 .nth(start_char_col)
252 .map(|(idx, _)| idx)
253 .unwrap_or(current_line.len());
254
255 let end_byte = current_line
256 .char_indices()
257 .nth(end_char_col)
258 .map(|(idx, _)| idx)
259 .unwrap_or(current_line.len());
260
261 let start = line_start + start_byte;
262 let end = line_start + end_byte.max(start_byte);
263 start..end
264 }
265
266 pub fn line_content_range(&self, line: usize) -> Range<usize> {
269 let line_idx = line.saturating_sub(1);
270 let line_start = *self.line_starts.get(line_idx).unwrap_or(&self.content.len());
271
272 let current_line = self.get_line(line_idx).unwrap_or("");
273 let line_end = line_start + current_line.len();
274 line_start..line_end
275 }
276
277 pub fn get_line_start_byte(&self, line_num: usize) -> Option<usize> {
279 if line_num == 0 {
280 return None; }
282 self.line_starts.get(line_num - 1).cloned()
284 }
285
286 pub fn is_code_block(&self, line: usize) -> bool {
288 if let Some(ref code_block_lines) = self.code_block_lines {
289 code_block_lines.contains(&line)
290 } else {
291 self.is_code_fence(line)
293 }
294 }
295
296 pub fn is_code_fence(&self, line: usize) -> bool {
298 self.get_line(line).is_some_and(|l| {
299 let trimmed = l.trim();
300 trimmed.starts_with("```") || trimmed.starts_with("~~~")
301 })
302 }
303
304 pub fn is_tilde_code_block(&self, line: usize) -> bool {
306 self.get_line(line).is_some_and(|l| l.trim().starts_with("~~~"))
307 }
308
309 pub fn get_content(&self) -> &str {
311 self.content
312 }
313
314 fn compute_code_block_lines(&mut self) {
316 let mut code_block_lines = HashSet::new();
317 let lines: Vec<&str> = self.content.lines().collect();
318
319 let mut in_block = false;
321 let mut active_fence_type = ' '; let mut block_indent = 0;
323 let mut block_fence_length = 0;
324 let mut in_markdown_block = false;
325 let mut nested_fence_start = None;
326 let mut nested_fence_end = None;
327
328 for (i, line) in lines.iter().enumerate() {
330 let trimmed = line.trim();
331 let indent = line.len() - trimmed.len();
332
333 if ElementCache::calculate_indentation_width_default(line) >= 4 {
335 code_block_lines.insert(i);
336 continue; }
338
339 if !in_block {
341 if trimmed.starts_with("```") || trimmed.starts_with("~~~") {
343 let char_type = if trimmed.starts_with("```") { '`' } else { '~' };
344 let count = trimmed.chars().take_while(|&c| c == char_type).count();
345 let info_string = if trimmed.len() > count {
346 trimmed[count..].trim()
347 } else {
348 ""
349 };
350
351 in_block = true;
353 active_fence_type = char_type;
354 block_indent = indent;
355 block_fence_length = count;
356 in_markdown_block = info_string == "markdown";
357 nested_fence_start = None;
358 nested_fence_end = None;
359
360 code_block_lines.insert(i);
361 }
362 } else {
363 code_block_lines.insert(i);
365
366 if in_markdown_block && nested_fence_start.is_none() && trimmed.starts_with("```") {
368 let count = trimmed.chars().take_while(|&c| c == '`').count();
370 let remaining = if trimmed.len() > count {
371 trimmed[count..].trim()
372 } else {
373 ""
374 };
375
376 if !remaining.is_empty() {
377 nested_fence_start = Some(i);
378 }
379 }
380
381 if in_markdown_block
383 && nested_fence_start.is_some()
384 && nested_fence_end.is_none()
385 && trimmed.starts_with("```")
386 && trimmed.trim_start_matches('`').trim().is_empty()
387 {
388 nested_fence_end = Some(i);
389 }
390
391 if trimmed.starts_with(&active_fence_type.to_string().repeat(3)) {
393 let count = trimmed.chars().take_while(|&c| c == active_fence_type).count();
394 let remaining = if trimmed.len() > count {
395 trimmed[count..].trim()
396 } else {
397 ""
398 };
399
400 let is_valid_closing_fence =
406 count >= block_fence_length && remaining.is_empty() && indent <= block_indent;
407
408 let is_nested_closing = nested_fence_end.is_some() && i == nested_fence_end.unwrap();
411
412 if is_valid_closing_fence && !is_nested_closing {
414 in_block = false;
415 in_markdown_block = false;
416 }
417 }
418 }
419 }
420
421 self.code_block_lines = Some(code_block_lines);
422 }
423}
424
425pub fn calculate_single_line_range(line: usize, start_col: usize, length: usize) -> (usize, usize, usize, usize) {
427 (line, start_col, line, start_col + length)
428}
429
430pub fn calculate_line_range(line: usize, line_content: &str) -> (usize, usize, usize, usize) {
432 let trimmed_len = line_content.trim_end().len();
433 (line, 1, line, trimmed_len + 1)
434}
435
436pub fn calculate_match_range(
442 line: usize,
443 line_content: &str,
444 match_start: usize,
445 match_len: usize,
446) -> (usize, usize, usize, usize) {
447 let line_len = line_content.len();
449 if match_start > line_len {
450 let char_count = line_content.chars().count();
452 return (line, char_count + 1, line, char_count + 1);
453 }
454
455 let safe_match_start = find_char_boundary(line_content, match_start);
457 let safe_match_end_byte = find_char_boundary(line_content, (match_start + match_len).min(line_len));
458
459 let char_start = byte_to_char_count(line_content, safe_match_start);
461 let char_len = if safe_match_end_byte > safe_match_start {
462 line_content[safe_match_start..safe_match_end_byte].chars().count()
464 } else {
465 0
466 };
467 (line, char_start, line, char_start + char_len)
468}
469
470pub fn calculate_trailing_range(line: usize, line_content: &str, content_end: usize) -> (usize, usize, usize, usize) {
476 let safe_content_end = find_char_boundary(line_content, content_end);
478 let char_content_end = byte_to_char_count(line_content, safe_content_end);
479 let line_char_len = line_content.chars().count() + 1;
480 (line, char_content_end, line, line_char_len)
481}
482
483pub fn calculate_heading_range(line: usize, line_content: &str) -> (usize, usize, usize, usize) {
485 calculate_line_range(line, line_content)
486}
487
488pub fn calculate_emphasis_range(
494 line: usize,
495 line_content: &str,
496 start_pos: usize,
497 end_pos: usize,
498) -> (usize, usize, usize, usize) {
499 let safe_start_pos = find_char_boundary(line_content, start_pos);
501 let safe_end_pos = find_char_boundary(line_content, end_pos);
502 let char_start = byte_to_char_count(line_content, safe_start_pos);
503 let char_end = byte_to_char_count(line_content, safe_end_pos);
504 (line, char_start, line, char_end)
505}
506
507pub fn calculate_html_tag_range(
509 line: usize,
510 line_content: &str,
511 tag_start: usize,
512 tag_len: usize,
513) -> (usize, usize, usize, usize) {
514 calculate_match_range(line, line_content, tag_start, tag_len)
515}
516
517pub fn calculate_url_range(
519 line: usize,
520 line_content: &str,
521 url_start: usize,
522 url_len: usize,
523) -> (usize, usize, usize, usize) {
524 calculate_match_range(line, line_content, url_start, url_len)
525}
526
527pub fn calculate_list_marker_range(
529 line: usize,
530 line_content: &str,
531 marker_start: usize,
532 marker_len: usize,
533) -> (usize, usize, usize, usize) {
534 calculate_match_range(line, line_content, marker_start, marker_len)
535}
536
537pub fn calculate_excess_range(line: usize, line_content: &str, limit: usize) -> (usize, usize, usize, usize) {
539 let char_limit = std::cmp::min(limit, line_content.chars().count());
540 let line_char_len = line_content.chars().count() + 1;
541 (line, char_limit + 1, line, line_char_len)
542}
543
544#[cfg(test)]
545mod tests {
546 use super::*;
547
548 #[test]
549 fn test_single_line_range() {
550 let (start_line, start_col, end_line, end_col) = calculate_single_line_range(5, 10, 3);
551 assert_eq!(start_line, 5);
552 assert_eq!(start_col, 10);
553 assert_eq!(end_line, 5);
554 assert_eq!(end_col, 13);
555 }
556
557 #[test]
558 fn test_line_range() {
559 let content = "# This is a heading ";
560 let (start_line, start_col, end_line, end_col) = calculate_line_range(1, content);
561 assert_eq!(start_line, 1);
562 assert_eq!(start_col, 1);
563 assert_eq!(end_line, 1);
564 assert_eq!(end_col, 20); }
566
567 #[test]
568 fn test_match_range() {
569 let content = "Text <div>content</div> more";
570 let tag_start = 5; let tag_len = 5; let (start_line, start_col, end_line, end_col) = calculate_match_range(1, content, tag_start, tag_len);
573 assert_eq!(start_line, 1);
574 assert_eq!(start_col, 6); assert_eq!(end_line, 1);
576 assert_eq!(end_col, 11); }
578
579 #[test]
580 fn test_trailing_range() {
581 let content = "Text content "; let content_end = 12; let (start_line, start_col, end_line, end_col) = calculate_trailing_range(1, content, content_end);
584 assert_eq!(start_line, 1);
585 assert_eq!(start_col, 13); assert_eq!(end_line, 1);
587 assert_eq!(end_col, 16); }
589
590 #[test]
591 fn test_excess_range() {
592 let content = "This line is too long for the limit";
593 let limit = 20;
594 let (start_line, start_col, end_line, end_col) = calculate_excess_range(1, content, limit);
595 assert_eq!(start_line, 1);
596 assert_eq!(start_col, 21); assert_eq!(end_line, 1);
598 assert_eq!(end_col, 36); }
600
601 #[test]
602 fn test_whole_line_range() {
603 let content = "Line 1\nLine 2\nLine 3";
604 let line_index = LineIndex::new(content);
605
606 let range = line_index.whole_line_range(1);
608 assert_eq!(range, 0..7); let range = line_index.whole_line_range(2);
612 assert_eq!(range, 7..14); let range = line_index.whole_line_range(3);
616 assert_eq!(range, 14..20); }
618
619 #[test]
620 fn test_line_content_range() {
621 let content = "Line 1\nLine 2\nLine 3";
622 let line_index = LineIndex::new(content);
623
624 let range = line_index.line_content_range(1);
626 assert_eq!(range, 0..6); let range = line_index.line_content_range(2);
630 assert_eq!(range, 7..13); let range = line_index.line_content_range(3);
634 assert_eq!(range, 14..20); }
636
637 #[test]
638 fn test_line_text_range() {
639 let content = "Hello world\nAnother line";
640 let line_index = LineIndex::new(content);
641
642 let range = line_index.line_text_range(1, 1, 5); assert_eq!(range, 0..4);
645
646 let range = line_index.line_text_range(2, 1, 7); assert_eq!(range, 12..18);
649
650 let range = line_index.line_text_range(1, 1, 100); assert_eq!(range, 0..11); }
654
655 #[test]
656 fn test_calculate_match_range_bounds_checking() {
657 let line_content = "] not a link [";
659 let (line, start_col, end_line, end_col) = calculate_match_range(121, line_content, 57, 10);
660 assert_eq!(line, 121);
661 assert_eq!(start_col, 15); assert_eq!(end_line, 121);
663 assert_eq!(end_col, 15); let line_content = "short";
667 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 2, 10);
668 assert_eq!(line, 1);
669 assert_eq!(start_col, 3); assert_eq!(end_line, 1);
671 assert_eq!(end_col, 6); let line_content = "normal text here";
675 let (line, start_col, end_line, end_col) = calculate_match_range(5, line_content, 7, 4);
676 assert_eq!(line, 5);
677 assert_eq!(start_col, 8); assert_eq!(end_line, 5);
679 assert_eq!(end_col, 12); let line_content = "test line";
683 let (line, start_col, end_line, end_col) = calculate_match_range(10, line_content, 5, 0);
684 assert_eq!(line, 10);
685 assert_eq!(start_col, 6); assert_eq!(end_line, 10);
687 assert_eq!(end_col, 6); }
689
690 #[test]
695 fn test_issue_154_korean_character_boundary() {
696 let line_content = "- 2023 년 초 이후 주가 상승 +1,000% (10 배 상승) ";
699
700 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 19, 1);
703
704 assert!(start_col > 0);
706 assert_eq!(line, 1);
707 assert_eq!(end_line, 1);
708 assert!(end_col >= start_col);
709 }
710
711 #[test]
712 fn test_calculate_match_range_korean() {
713 let line_content = "안녕하세요";
716 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 3, 3);
718 assert_eq!(line, 1);
719 assert_eq!(start_col, 2); assert_eq!(end_line, 1);
721 assert_eq!(end_col, 3); let (line, start_col, end_line, _end_col) = calculate_match_range(1, line_content, 4, 3);
725 assert_eq!(line, 1);
726 assert_eq!(start_col, 2); assert_eq!(end_line, 1);
728 }
729
730 #[test]
731 fn test_calculate_match_range_chinese() {
732 let line_content = "你好世界";
735 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 6, 3);
737 assert_eq!(line, 1);
738 assert_eq!(start_col, 3); assert_eq!(end_line, 1);
740 assert_eq!(end_col, 4); }
742
743 #[test]
744 fn test_calculate_match_range_japanese() {
745 let line_content = "こんにちは";
748 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 9, 3);
750 assert_eq!(line, 1);
751 assert_eq!(start_col, 4); assert_eq!(end_line, 1);
753 assert_eq!(end_col, 5); }
755
756 #[test]
757 fn test_calculate_match_range_mixed_unicode() {
758 let line_content = "Hello 世界";
763
764 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 5, 1);
766 assert_eq!(line, 1);
767 assert_eq!(start_col, 6); assert_eq!(end_line, 1);
769 assert_eq!(end_col, 7); let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 6, 3);
773 assert_eq!(line, 1);
774 assert_eq!(start_col, 7); assert_eq!(end_line, 1);
776 assert_eq!(end_col, 8); }
778
779 #[test]
780 fn test_calculate_trailing_range_korean() {
781 let line_content = "안녕하세요 ";
783 let (line, start_col, end_line, end_col) = calculate_trailing_range(1, line_content, 15);
785 assert_eq!(line, 1);
786 assert!(start_col > 0);
787 assert_eq!(end_line, 1);
788 assert!(end_col > start_col);
789 }
790
791 #[test]
792 fn test_calculate_emphasis_range_chinese() {
793 let line_content = "这是**重要**的";
795 let (line, start_col, end_line, end_col) = calculate_emphasis_range(1, line_content, 6, 12);
797 assert_eq!(line, 1);
798 assert!(start_col > 0);
799 assert_eq!(end_line, 1);
800 assert!(end_col > start_col);
801 }
802
803 #[test]
804 fn test_line_col_to_byte_range_korean() {
805 let content = "안녕하세요\nWorld";
807 let line_index = LineIndex::new(content);
808
809 let range = line_index.line_col_to_byte_range(1, 1);
811 assert_eq!(range, 0..0);
812
813 let range = line_index.line_col_to_byte_range(1, 2);
815 assert_eq!(range, 3..3); let range = line_index.line_col_to_byte_range(1, 3);
819 assert_eq!(range, 6..6); }
821
822 #[test]
823 fn test_line_col_to_byte_range_with_length_chinese() {
824 let content = "你好世界\nTest";
826 let line_index = LineIndex::new(content);
827
828 let range = line_index.line_col_to_byte_range_with_length(1, 1, 2);
830 assert_eq!(range, 0..6); let range = line_index.line_col_to_byte_range_with_length(1, 2, 1);
834 assert_eq!(range, 3..6); }
836
837 #[test]
838 fn test_line_text_range_japanese() {
839 let content = "こんにちは\nHello";
841 let line_index = LineIndex::new(content);
842
843 let range = line_index.line_text_range(1, 2, 4);
845 assert_eq!(range, 3..9); }
847
848 #[test]
849 fn test_find_char_boundary_edge_cases() {
850 let s = "안녕";
852
853 assert_eq!(find_char_boundary(s, 0), 0);
855
856 assert_eq!(find_char_boundary(s, 1), 0);
858
859 assert_eq!(find_char_boundary(s, 2), 0);
861
862 assert_eq!(find_char_boundary(s, 3), 3);
864
865 assert_eq!(find_char_boundary(s, 4), 3);
867
868 assert_eq!(find_char_boundary(s, 100), s.len());
870 }
871
872 #[test]
873 fn test_byte_to_char_count_unicode() {
874 let s = "안녕하세요";
876
877 assert_eq!(byte_to_char_count(s, 0), 1);
879
880 assert_eq!(byte_to_char_count(s, 3), 2);
882
883 assert_eq!(byte_to_char_count(s, 6), 3);
885
886 assert_eq!(byte_to_char_count(s, 9), 4);
888
889 assert_eq!(byte_to_char_count(s, 12), 5);
891
892 assert_eq!(byte_to_char_count(s, 15), 6);
894 }
895
896 #[test]
897 fn test_all_range_functions_with_emoji() {
898 let line_content = "Hello 🎉 World 🌍";
900
901 let (line, start_col, end_line, end_col) = calculate_match_range(1, line_content, 6, 4);
903 assert_eq!(line, 1);
904 assert!(start_col > 0);
905 assert_eq!(end_line, 1);
906 assert!(end_col > start_col);
907
908 let (line, start_col, end_line, end_col) = calculate_trailing_range(1, line_content, 12);
910 assert_eq!(line, 1);
911 assert!(start_col > 0);
912 assert_eq!(end_line, 1);
913 assert!(end_col > start_col);
914
915 let (line, start_col, end_line, end_col) = calculate_emphasis_range(1, line_content, 0, 5);
917 assert_eq!(line, 1);
918 assert_eq!(start_col, 1);
919 assert_eq!(end_line, 1);
920 assert!(end_col > start_col);
921 }
922}