🏠 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.


#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,