🏠 back to Observable

default values + argument unpacking causes observable syntax highlighter to slightly break


#1

In the following, both a and b should be parsed as arguments:

f = ([a=1, b=2]) => a + b

But in Observable’s code viewer, a is colored black while b is gray.


Parameter object destructuring not recognized by syntax highlighter
#2

Thanks for identifying this issue! It’s an upstream bug in CodeMirror, which we use for text editing. I’ve written a PR to fix it in CodeMirror for everyone, and once that’s resolved we’ll pull changes back down to fix it in Observable.


#3

I assumed as much. I was just too lazy to track the bug further upstream. Thanks!


#4

While you’re at it :slight_smile:, some syntax highlighting bugs occurring with multiline function signatures :


#5

We’re discovering a lot of things to fix in CM :slight_smile: The first bug - defaults in array destructuring - is fixed upstream in CodeMirror and deployed to Observable. Looking into the second, which might be a bit trickier. CodeMirror’s syntax highlighting is streaming/online so it doesn’t really backtrack, which means that its arrow-function highlighting relies on this self-described ‘crude hack’, which, in this case, is apparently too crude.


#6

Wow, what a fast turnaround! Awesome.

My code highlights correctly now,


#7

i_cant_live_like_this

Look above. Now, look at me. Now, look back above. Now, look back at me.

The variables defined in the destructured object parameter are not recognized by the syntax highlighter. They appear as faded, which implies the variable has not been in previous context. This is false. The variable selectedTopic should be blue.