bhauman / rebel-readline

Terminal readline library for Clojure dialects
Eclipse Public License 1.0
684 stars 37 forks source link

wrong parens matching when `(` in regex #201

Open birdspider opened 4 years ago

birdspider commented 4 years ago

Problem

paren detection detects/uses parens in regular expression

Cause

#"reboot\s+system\s+boot\s+\S+\s+([^\(]+)\((.+)\)"
;                                ^
;                                |
; this wrongfully get detected as part of s-expression paren

Example the following code is balanced/correct but the rebel-readline hints wrongly. adding a ) hints the first ( giving the impression that a paren is missing - due to (above) missdetection on the opening paren in the re

user=> (require 'clojure.java.shell)
nil
user=> (let [data (re-seq #"reboot\s+system\s+boot\s+\S+\s+([^\(]+)\((.+)\)"
  #_=>                    (:out (clojure.java.shell/sh "/usr/bin/last" "-x" "reboot")))]
  #_=>   (map last data))
;                        ^
;                        |
; add ')' here, you'll see it matches/hints the let '(' 

misc

does not happen with rlwrap clojure nor with lein repl; clojure 1.10.1