Creating a table sometimes insert empty lines between rows, breaking the table

AI-generated summary

A bug in the table builder feature is causing empty lines to be inserted between rows when there are empty lines below the table builder’s line. This issue was first reported by Canapin and has been ongoing.

seanblue described the issue and provided an example of the problem, noting that it results in confusing edit history. seanblue followed up on the issue, inquiring about plans to investigate.

nathank also encountered the issue and found that it occurs when the cursor is not at the very bottom of the post.

Lhc_fl investigated the issue and believes it is caused by arrayToTable using \r\n. They suggested a fix using \n instead, but are unsure if it will work on Mac.

Lhc_fl later provided a link to a GitHub pull request that should fix the bug: https://github.com/discourse/discourse/pull/27711

Empty lines will be added inside the table layout if there are empty lines below the line on which we’re going to use the table builder.

No issue:

If there’s a line (empty or not, it doesn’t matter) directly below the table builder’s line, there will be an empty line just below the header’s separator:

:information_source: Multiple filled lines below each other will trigger the same behavior: only one empty line will be added below the header’s separator in the table layout.

However, if there are multiple empty lines below the table builder’s line, there will be additional empty lines in the table layout, between the body’s rows.

For example, if there are 3 empty lines below, there will be a total of 3 empty lines in the table’s layout.
One under the separator, and one between the first two table body’s rows:

6 Likes

I’m reporting this bug that has been noticed and reported a while ago but isn’t fixed yet so that it can be tracked more easily. :slight_smile:


Empty lines will be added inside the table layout if there are empty lines below the line on which we’re going to use the table builder.

No issue:

If there’s a line (empty or not, it doesn’t matter) directly below the table builder’s line, there will be an empty line just below the header’s separator:

:information_source: Multiple filled lines below each other will trigger the same behavior: only one empty line will be added below the header’s separator in the table layout.

However, if there are multiple empty lines below the table builder’s line, there will be additional empty lines in the table layout, between the body’s rows.

For example, if there are 3 empty lines below, there will be a total of 3 empty lines in the table’s layout.
One under the separator, and one between the first two table body’s rows:

2 Likes

When using the table editor feature, it sometimes adds blank lines between every row in the table for no apparent reason. This results in confusing edit history, as it adds these lines automatically and then people remove them manually (wiki post). For example:

Table for testing:

Column 1 Column 2 Column 3
Row 1 val 1 Row 1 val 2 Row 1 val 3
Row 2 val 1 Row 2 val 2 (modified with editor) Row 2 val 3
Row 3 val 1 Row 3 val 2 Row 3 val 3

I’m unsure of the exact steps to reproduce, as editing an entry here didn’t cause it, but it happens frequently on the wiki post here.

1 Like

I wanted to follow up on this, as it’s still a problem. Is there any plan to look into this?

I think we have an existing bug topic on this with a pr-welcome tag?

Let me see if I can tidy things up…

2 Likes

I’ve just been tripped up by this in my instance when creating a new table, but it doesn’t seem to happen here in Meta.

Actually - yes it does!!!

|Column 1 | Column 2|

|— | —|

|testing | testing|
|testing | testing|

The key issue is if that it happens when the cursor is not at the very bottom of the post.

3 Likes

After my investigation, this seems to be caused by arrayToTable using \r\n :thinking:

In my experience on Windows, using just \n fixes this problem. But I’m not sure if it will work on Mac. :face_holding_back_tears:

2 Likes

This should fix this bug:

https://github.com/discourse/discourse/pull/27711

7 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.