Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: handle edge cases in the tokenizer for syntax highlighting in the REPL #2770

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/repl/lib/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
*/
function onToken( token ) {
// Ignore placeholders & EOF tokens:
if ( token.start === token.end ) {
if ( token.start >= token.end ) {
return;
}
if ( token.type.isLoop || isControlKeyword( token.type.keyword ) || ( token.type.label === 'name' && isUnrecognizedControlKeyword( token.value ) ) ) {
Expand Down Expand Up @@ -173,7 +173,7 @@
*/
function onComment( block, text, start, end ) {
if ( block ) {
// TODO: add support for highlighting multi-line comments.

Check warning on line 176 in lib/node_modules/@stdlib/repl/lib/tokenizer.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: add support for highlighting...'
return;
}
tokens.push({
Expand All @@ -196,7 +196,7 @@
var i;

// Ignore placeholder nodes:
if ( node.start === node.end ) {
if ( node.start >= node.end ) {
return true;
}
// Ignore node if it is an unrecognized `keyword`:
Expand Down Expand Up @@ -275,7 +275,7 @@
var obj;

// Ignore placeholder nodes:
if ( node.start === node.end ) {
if ( node.start >= node.end ) {
return;
}

Expand Down Expand Up @@ -308,7 +308,7 @@
property = properties.next();
while ( !property.done ) {
// Ignore placeholder nodes:
if ( property.value.start === property.value.end ) {
if ( property.value.start >= property.value.end ) {
return;
}
// Case: 'bar' in `foo['bar']` - property already pushed as a string token. Ignore...
Expand Down
Loading