diff --git a/src/uTop_console.ml b/src/uTop_console.ml index f93efab..b59ad55 100644 --- a/src/uTop_console.ml +++ b/src/uTop_console.ml @@ -359,91 +359,7 @@ object(self) loop_sharp tokens; (* Parenthesis matching. *) - - if not last && Array.length styled > 0 then begin - let rec rsearch idx left right depth = - if idx >= Array.length styled then - None - else - let ch, _ = styled.(idx) in - if ch = right then - if depth = 0 then - Some idx - else - rsearch (idx + 1) left right (depth - 1) - else if ch = left then - rsearch (idx + 1) left right (depth + 1) - else - rsearch (idx + 1) left right depth - in - let rec lsearch idx left right depth = - if idx < 0 then - None - else - let ch, _ = styled.(idx) in - if ch = left then - if depth = 0 then - Some idx - else - lsearch (idx - 1) left right (depth - 1) - else if ch = right then - lsearch (idx - 1) left right (depth + 1) - else - lsearch (idx - 1) left right depth - in - let matched = - if position = Array.length styled then - false - else - let ch, _ = styled.(position) in - match - if ch = lparen then - rsearch (position + 1) lparen rparen 0 - else if ch = lbrace then - rsearch (position + 1) lbrace rbrace 0 - else if ch = lbracket then - rsearch (position + 1) lbracket rbracket 0 - else if ch = rparen then - lsearch (position - 1) lparen rparen 0 - else if ch = rbrace then - lsearch (position - 1) lbrace rbrace 0 - else if ch = rbracket then - lsearch (position - 1) lbracket rbracket 0 - else - None - with - | Some idx -> - let ch, style = styled.(idx) in - styled.(idx) <- (ch, LTerm_style.merge styles.style_paren style); - true - | None -> - false - in - if not matched && position > 0 then - let ch, style = styled.(position - 1) in - match - if ch = lparen then - rsearch (position + 1) lparen rparen 0 - else if ch = lbrace then - rsearch (position + 1) lbrace rbrace 0 - else if ch = lbracket then - rsearch (position + 1) lbracket rbracket 0 - else if ch = rparen then - lsearch (position - 2) lparen rparen 0 - else if ch = rbrace then - lsearch (position - 2) lbrace rbrace 0 - else if ch = rbracket then - lsearch (position - 2) lbracket rbracket 0 - else - None - with - | Some idx -> - styled.(position - 1) <- (ch, LTerm_style.merge styles.style_paren style); - let ch, style = styled.(idx) in - styled.(idx) <- (ch, LTerm_style.merge styles.style_paren style) - | None -> - () - end; + if not last then LTerm_text.stylise_parenthesis styled position styles.style_paren; (styled, position)