Skip to content

Commit

Permalink
improve parentparnteses matching
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Apr 3, 2024
1 parent ba64fbc commit ff3c697
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,25 @@ function run_repl(err, rl) {
const prefix = multiline ? continue_prompt : prompt;
const current_line = prefix + rl.line;
let code = scheme(string);
let code_above = cmd && scheme(cmd.substring(0, cmd.length - 1));
if (rl.line[rl.cursor - 1] === ')') {
const substring = rl.line.substring(0, rl.cursor);
const input = prefix + substring;
const token = matched_token(input);
if (token) {
code = mark_paren(code, token);
} else if (cmd) {
const input = cmd + rl.line;
const token = matched_token(input);
if (token) {
code_above = mark_paren(code_above, token);
}
}
}
// ignore the process when user press enter
if (code_above && !string.match(/^[\n\r]+$/)) {
process.stdout.write(ansi_rewrite_above(code_above));
}
rl.output.write(code);
} catch(e) {
console.error(e);
Expand Down

0 comments on commit ff3c697

Please sign in to comment.