Open Iain-S opened 4 years ago
Hi @Iain-S , thank you for the PR
Actually I haven't tested this yet. Do you have any problem so far with your fix?
Hi @dnanhkhoa , I haven't noticed any issues thus far.
A minor problem is that if the user has started to add new blank lines after submission but before completion of the cell, those new lines will be deleted. I suspect that this will be only a minor annoyance but an alternative solution would be to work out why the self.shell.user_ns[]
code is stripped of whitespace.
Issue If you have trailing whitespace in a Jupyter notebook cell, nb-black won't format it. For example (note the newline):
I have tested it with newlines and spaces.
Fix It happens because
nbb_unformatted_code
(which comes fromself.shell.user_ns["_i" + str(cell_id)]
) is stripped of whitespace (not sure why but it is out of our control). Therefore, we should strip whitespace fromnbb_cells[i].get_text()
before we compare it tonbb_unformatted_code
.