observablehq / feedback

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

Cell formatting stops working when class instance fields are present #464

Open RLesser opened 2 years ago

RLesser commented 2 years ago

Describe the bug When a cell contains a class, and that class contains private class features, formatting seems to stop working.

To Reproduce Steps to reproduce the behavior:

  1. Create a cell
  2. Create a class in the cell with a line that should get formatted, and also has a private class feature:
    class Test {
    #foo = 1;
    constructor() {
    const veryLongVariableNameRepresenting1 = 1;
    const veryLongVariableNameRepresenting2 = 2;
    // intially written as a single line
    const veryLongVariableNameRepresenting3 = veryLongVariableNameRepresenting1 + veryLongVariableNameRepresenting2;
    }
    }
  3. Saving the cell results. The line will not be reformatted.

Expected behavior The last line should be reformatted into two lines.

Desktop (please complete the following information):

CobusT commented 2 years ago

I think this is happening with any instance field, right? Does it work if you have:

class Test {
  foo = 1;
  constructor() {
    const veryLongVariableNameRepresenting1 = 1;
    const veryLongVariableNameRepresenting2 = 2;
    // intially written as a single line
    const veryLongVariableNameRepresenting3 = veryLongVariableNameRepresenting1 + veryLongVariableNameRepresenting2;
  }
}
RLesser commented 2 years ago

Yep, happening with any instance field, not just private. Good catch!