markdown-mode icon indicating copy to clipboard operation
markdown-mode copied to clipboard

Strange editing behavior for indented tables

Open saf-dmitry opened this issue 3 years ago • 0 comments

First I would thank @syohex and other developers and contributors for fixing lots of issues around table editing 👍. Unfortunately, I found another one, which I didn't experience before.

The documentation says:

The indentation of the table is set by the first line

This is practical for including tables in e.g. multi-paragraph list items. However, when I indent the first line of a table and press TAB to walk through the cells, I notice strange behavior I didn't see before when working with indented tbles:

  1. After the last table cell a new row is created, but this row is not indented properly to match the table indent. Only at the next TAB the whole table will be properly indented and aligned.
  2. After the last header cell cursor doesn't jump to the first body cell, but creates a new (also not indented) header row instead.

Expected Behavior

When hitting TAB repeatedly new properly indented rows should be created only at the end of a table.

Actual Behavior

When hitting TAB repeatedly new rows are created after the header row (the cursor should jump to the first body cell instead). New rows, created at the end of a table are not properly indented.

Steps to Reproduce

  1. Put following table in a Markdown buffer (here dots at BOL indicated leading spaces!):

    ..| 1 | 2 | 3 |
    ..|---|---|---|
    ..| 4 | 5 | 6 |
    
  2. Place cursor at the last header cell (| 3 |) and press TAB.

  3. See a new misaligned header row created:

    ..| 1 | 2 | 3 |
    |   |   |   |
    ..|---|---|---|
    ..| 4 | 5 | 6 |
    
  4. Recreate table from No.1, place the cursor at the last table cell (| 6 |) and press TAB.

  5. See a new misaligned row created:

    ..| 1 | 2 | 3 |
    ..|---|---|---|
    ..| 4 | 5 | 6 |
    |   |   |   |
    

Additional Information

Looking at this lines in the definition of markdown-table-forward-cell I wonder if the described behavior for creating new header rows is intentional:

(if (looking-at "[-:]")
    (progn
      (beginning-of-line 0)
      (markdown-table-insert-row 'below))
 (when (looking-at " ") (forward-char 1))))

But for unindented tables it works differently 😕.

Software Versions

  • Markdown Mode: From Git on 2021-08-15
  • Emacs: 26.3
  • OS: macOS Mojave

saf-dmitry avatar Aug 15 '21 11:08 saf-dmitry