diff options
-rw-r--r-- | src/readline.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/readline.rs b/src/readline.rs index f59cd22..9912af6 100644 --- a/src/readline.rs +++ b/src/readline.rs | |||
@@ -62,10 +62,12 @@ impl Highlighter for LineHighlighter { | |||
62 | let mut coloured: String = ops.replace_all(line, "\x1b[35m$o\x1b[0m").into(); | 62 | let mut coloured: String = ops.replace_all(line, "\x1b[35m$o\x1b[0m").into(); |
63 | 63 | ||
64 | for c in &constants { | 64 | for c in &constants { |
65 | coloured = coloured.replace(c, &format!("\x1b[33m{}\x1b[0m", c)); | 65 | let re = Regex::new(format!("(?P<o>{})(?P<r>(\x1b\\[35m)?([\\+-/\\*%\\^! ]|$))", c).as_str()).unwrap(); |
66 | coloured = re.replace_all(&coloured, "\x1b[33m$o\x1b[0m$r").into(); | ||
66 | } | 67 | } |
67 | for f in &functions { | 68 | for f in &functions { |
68 | coloured = coloured.replace(f, &format!("\x1b[34m{}\x1b[0m", f)); | 69 | let re = Regex::new(format!("(?P<o>{})(?P<r>(\\(|$))", f).as_str()).unwrap(); |
70 | coloured = re.replace_all(&coloured, "\x1b[34m$o\x1b[0m$r").into(); | ||
69 | } | 71 | } |
70 | Owned(coloured) | 72 | Owned(coloured) |
71 | } | 73 | } |