aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaximilian Bosch <[email protected]>2021-12-26 14:27:41 +0000
committerMaximilian Bosch <[email protected]>2021-12-30 17:06:49 +0000
commitacf947b608db99ff2e46a8020b6e70466c233088 (patch)
tree4cd50bec99cb3a63fe5bdb36331c4966ebdfb960 /src
parent4fd3ec330a89e4177099c21277d3c12e97ca0c21 (diff)
Fix highlighting of `e` vs `exp`
Diffstat (limited to 'src')
-rw-r--r--src/readline.rs6
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 }