feedback icon indicating copy to clipboard operation
feedback copied to clipboard

Cell formatting stops working when class instance fields are present

Open RLesser opened this issue 3 years ago • 2 comments

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;
  }
}
  1. 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):

  • OS: macOS
  • Browser: Chrome
  • Version: 101

RLesser avatar Jul 08 '22 15:07 RLesser

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;
  }
}

CobusT avatar Jul 08 '22 22:07 CobusT

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

RLesser avatar Jul 09 '22 00:07 RLesser