observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

Prettier unmarks external cell references #432

Open mootari opened 2 years ago

mootari commented 2 years ago

Describe the bug

Formatting a cell with Prettier removes the underline style from external cell names.

In the GIF below Prettier is applied via the shortcut Shift-Option-F:

Kapture 2022-05-28 at 09 59 54

To Reproduce Steps to reproduce the behavior:

  1. Focus a cell editor that contains external references.
  2. If Prettier is enabled, simply resave the cell. Otherwise press Shift+Option+F (on Mac) to apply Prettier.
mbostock commented 2 years ago

This bug isn’t specific to Prettier. If you select all, cut, then immediately paste back and evaluate a cell, you also lose the cell reference styles. In my view there’s one bug and one (significant) “enhancement” here:

The bug is that when you evaluate a cell (e.g., with Shift-Return), it should ensure that all cell references are properly highlighted. It looks like when the contents of the cell didn’t actually change when you edit, we don’t refresh cell reference highlights.

The enhancement is that we should update cell references on every edit (keystroke) rather than waiting for the cell to be evaluated.

I’d much prefer that we implement the enhancement, which would conveniently obviate the bug. 😄