vscode-restructuredtext / vscode-restructuredtext

reStructuredText Language Support in Visual Studio Code
https://marketplace.visualstudio.com/items/lextudio.restructuredtext
Other
348 stars 93 forks source link

Some editing functions don't work on tables #316

Closed JamesRandom closed 3 years ago

JamesRandom commented 3 years ago

Environment

Expected behavior

Using the tab key should indent text. Using the return key should insert a newline.

Actual behavior

When a table is selected, indenting with Tab no longer works. A workaround is to select some text either side of the table as well. Also, it is not possible to insert a tab (or newline) inside the table. The tab key does nothing inside a table. The return key highlights the next cell in the table.

Just noticed this bug only manifests when the table is completely unindented. If the table is already indented, then these keys.

Given a partially completed table like this:

+--------+-----------------------+
+========+=======================+
| Item 1 | Description of item 1 |
+--------+-----------------------+
| Item 2 | Description of item 2 |
+--------+-----------------------+

I expect to be able to insert a blank line between the two dividers by using the return key (either at the end of the first line or the start of the second line), resulting in this:

 +--------+-----------------------+

 +========+=======================+
 | Item 1 | Description of item 1 |
 +--------+-----------------------+
 | Item 2 | Description of item 2 |
 +--------+-----------------------+

However, neither of those operations work as expected. And they both do different things.

Positioning the cursor at the end of the first divider line (---+) and hitting return does not insert a blank line but moves the whole table down one line (inserts a line before the table!)

Positioning the cursor at the start of the +=== ... line and hitting return results in a very strange edit:

+--------+-----------------------+
| Item 1 | Description of item 1 |
+========+=======================+
| Item 2 | Description of item 2 |
+--------+-----------------------+

Not what is desired at all.

This makes the extension unusable when editing tables.

lextm commented 3 years ago

First, it is rarely useful to tab indent in a grid table cell. That's why Tatsuya Nakamori decided to override its behavior (to move cursor to the next cell in the same row (if possible).

Second, fixing a partial completed grid table can be hard, but you can always generate a new grid table of the same size and cut/paste the useful parts over.

Thus, there is no plan to change anything at this moment.

If you want to create a table that is not affected by table editor's restrictions, you can use the simple table syntax,

=====  ===
A      simple
=====  ===
table  here
for    you
=====  ===
JamesRandom commented 3 years ago

First, it is rarely useful to tab indent in a grid table cell.

I do it frequently. Typically to put an existing table under a .. table:: directive.

Would it be possible to have an option to disable the table editor?

lextm commented 3 years ago

For release 161.0.0 and above, you can disable table editor via,

{
    "restructuredtext.editor.tableEditor.disabled": true
}