From 2e3871d22d053ea9d6fd5ed175d4dced8ba42366 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 8 Aug 2024 07:26:06 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 4 +++- CONTRIBUTORS | 1 + lib/syntax_highlighter.js | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14fd80b..14a4519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-08-01) +## Unreleased (2024-08-08)
@@ -41,6 +41,7 @@ ##### Bug Fixes +- [`e9c6d40`](https://github.com/stdlib-js/stdlib/commit/e9c6d40b6d4d382f39d2000c1996bd7ccb38bb29) - remove syntax highlighting upon encountering invalid JS [(#2758)](https://github.com/stdlib-js/stdlib/pull/2758) - [`9147f69`](https://github.com/stdlib-js/stdlib/commit/9147f69c07d3beda24bfa63870694fbf7500d707) - `example` command hanging in REPL when executing multi-line code - [`3efb708`](https://github.com/stdlib-js/stdlib/commit/3efb708f62e31603de837db5621522471046b27d) - address duplicate token bug when syntax-highlighting [(#2542)](https://github.com/stdlib-js/stdlib/pull/2542) - [`d2cd4c3`](https://github.com/stdlib-js/stdlib/commit/d2cd4c355302240f3cc5ea050d349715925be744) - pass options when parsing to suppress warnings in the REPL [(#2430)](https://github.com/stdlib-js/stdlib/pull/2430) @@ -274,6 +275,7 @@ A total of 9 people contributed to this release. Thank you to the following cont
+- [`e9c6d40`](https://github.com/stdlib-js/stdlib/commit/e9c6d40b6d4d382f39d2000c1996bd7ccb38bb29) - **fix:** remove syntax highlighting upon encountering invalid JS [(#2758)](https://github.com/stdlib-js/stdlib/pull/2758) _(by Snehil Shah)_ - [`19abe48`](https://github.com/stdlib-js/stdlib/commit/19abe4839bccbe8b48fbe92f5fe9737f304a5cd9) - **docs:** update REPL namespace documentation [(#2722)](https://github.com/stdlib-js/stdlib/pull/2722) _(by stdlib-bot, Athan Reines)_ - [`9147f69`](https://github.com/stdlib-js/stdlib/commit/9147f69c07d3beda24bfa63870694fbf7500d707) - **fix:** `example` command hanging in REPL when executing multi-line code _(by Snehil Shah)_ - [`70eb789`](https://github.com/stdlib-js/stdlib/commit/70eb789d85da0d8470a61b28ed0a80ee1009d179) - **docs:** update REPL namespace documentation [(#2682)](https://github.com/stdlib-js/stdlib/pull/2682) _(by stdlib-bot, Philipp Burckhardt)_ diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 26a1c46..f05b39c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -70,6 +70,7 @@ Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Rutam <138517416+performant23@users.noreply.github.com> Ryan Seal Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com> +SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com> Seyyed Parsa Neshaei Shashank Shekhar Singh Shivam <11shivam00@gmail.com> diff --git a/lib/syntax_highlighter.js b/lib/syntax_highlighter.js index dbe1c84..f2d9c31 100644 --- a/lib/syntax_highlighter.js +++ b/lib/syntax_highlighter.js @@ -328,20 +328,20 @@ setNonEnumerableReadOnly( SyntaxHighlighter.prototype, 'onKeypress', function on if ( this._line !== this._rli.line ) { // Tokenize: debug( 'Line change detected. Tokenizing line: %s', this._rli.line ); - tokens = tokenizer( this._rli.line, this._repl._context ); + this._line = this._rli.line; // update line buffer + tokens = tokenizer( this._line, this._repl._context ); if ( isEmptyArray( tokens ) ) { debug( 'No tokens found. Skipping highlighting...' ); - this._multilineHandler.updateLine( this._rli.line ); // save displayed line - return; + this._highlightedLine = this._line; + } else { + // Process tokens: + tokens.sort( tokenComparator ); + tokens = removeDuplicateTokens( tokens ); + + // Highlight: + debug( '%d tokens found. Highlighting...', tokens.length ); + this._highlightedLine = this._highlightLine( this._line, tokens ); } - // Process tokens: - tokens.sort( tokenComparator ); - tokens = removeDuplicateTokens( tokens ); - - // Highlight: - debug( '%d tokens found. Highlighting...', tokens.length ); - this._line = this._rli.line; // updated line buffer - this._highlightedLine = this._highlightLine( this._line, tokens ); } // Replace: debug( 'Replacing current line with the highlighted line...' );