🏠 back to Observable

Unexpected merge cells behavior

When merging to cells that contain only markdown, I expected the result to be one block of markdown in the same tagged template literal, so:

cell 1: mdHere is some prose.

cell 2 md Here is some more prose.

becomes…

combined cell: mdHere is some prose. Here is some more prose.

Instead, the merged cells contains: mdHere is some prose.mdHere is some more prose. and throws a “SyntaxError: Unexpected token”.

Also, if one of the cells to be merged hasn’t run yet, then that cell disappears after merging.

Merging and splitting doesn’t currently have any “smarts” about what’s in the cells. It’s not feasible in general to combine (or likewise separate) arbitrary chunks of JavaScript and have them do what you expect, so we chose the simplest possible behavior, with the expectation that you’ll edit the code after merging or splitting.

That said, we’ve talked about doing what you describe specifically for cells that consist solely of a possibly-tagged template literal, since you can reasonably merge or split text and markup. Stay tuned.

Also, if one of the cells to be merged hasn’t run yet, then that cell disappears after merging.

Merging by definition removes a cell: it merges the current cell into the previous or next cell. Are you seeing something else? (Observable also automatically deletes empty cells on blur, but only if those cells only contain whitespace.)

1 Like

Thanks for response, @mbostock. Smarter merging of markup cells would be a nice-to-have.

That bit that you quoted back back to me was poor wording on my part. What I meant to say was “If one of the cells to be merged hasn’t run yet, then that cell’s input disappears after merging.”

For whatever it’s worth (and not related to gordo’s bug report here), I would rather not have it try to do anything clever. Letting the user manually merge the content seems good to me.

3 Likes

Thanks for the report!