1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Bracket pair matching for syntax highlighting.
//!
//! This module provides functionality to find matching bracket pairs at the cursor position.
//! It supports parentheses (), square brackets [], and curly braces {}.
use crateTextObjectScope;
use cratefind_bracket_bounds;
/// Finds matching bracket pair positions when cursor is on a bracket.
///
/// Returns `Some((open_pos, close_pos))` if cursor is on a bracket character
/// and a matching pair exists. Returns `None` if cursor is not on a bracket
/// or no matching bracket is found.
///
/// # Parameters
/// - `query`: The query string to search in
/// - `cursor_pos`: Current cursor position (0-indexed character position)
///
/// # Returns
/// - `Some((open_pos, close_pos))`: Positions of opening and closing brackets
/// - `None`: Cursor not on bracket or no match found
///
/// # Examples
/// ```
/// use jiq::syntax_highlight::bracket_matcher::find_matching_bracket;
///
/// let query = "map(.)";
/// let result = find_matching_bracket(query, 3); // cursor on '('
/// assert_eq!(result, Some((3, 5))); // positions of '(' and ')'
/// ```