Project

General

Profile

Actions

Feature #44061

closed

Support Tab/Shift+Tab indentation of selected textarea lines in CommonMark Markdown

Added by Mizuki ISHIKAWA about 1 month ago. Updated 16 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Text formatting
Target version:
Resolution:
Fixed

Description

Add Tab / Shift+Tab support for indenting and unindenting list items in the wiki textarea when CommonMark formatting is used.

- Tab indents the current list item.
- Bullet list items (`-`, `*`, `+`) are indented by 2 spaces.
- Ordered list items (`1.`, `2)`, …) are indented by 4 spaces.
- Shift+Tab unindents the current list item by removing leading spaces.
- If the current indentation is smaller than the step size, only the existing spaces are removed.
- If there is no indentation, nothing is changed.

On non-list lines, Tab keeps its normal browser behavior and moves focus.

This feature applies only to CommonMark formatting. Textile uses repeated markers such as `*`, `**`, and `***` for nested lists, so indentation shortcuts are not needed.


Files

Actions #1

Updated by Go MAEDA about 1 month ago

Thank you for posting the patch to improve UI.

While allowing list indentation with the Tab key would certainly improve the usability, there is one concern. When users repeatedly press the Tab key to move between input fields, if focus lands on a textarea containing a bulleted list, pressing Tab would stop moving the focus to the next field and instead indent the list.

Actions #2

Updated by Florian Walchshofer 29 days ago

Thank you for the patch!
This is something that has been bothering me as well — working with list items in CommonMark can feel a bit clumsy, especially when it comes to indentation.
At the same time, I agree that overriding the default Tab behavior is problematic, since users rely on it for normal form navigation.
To address this, the behavior has been adjusted so that Tab / Shift+Tab indentation is only triggered when there is a clear editing intent:

  • Indentation is only applied when text is selected (selection present)
  • Supports multi-line selections, allowing multiple list items to be indented/unindented at once
  • When there is no selection, Tab retains its default browser behavior (focus moves to the next field)
  • This avoids interfering with standard form navigation while still enabling efficient list editing

This approach follows patterns used in tools like GitHub, where structural editing is tied to active selection.

Actions #3

Updated by Mizuki ISHIKAWA 27 days ago

Florian Walchshofer

Thank you for the suggestion and the patch. I tried running the code, and it looks very good.

With the approach in your patch, since it does not interfere with the existing Tab navigation, I think we may not need to limit indentation only to list items. Markdown has syntax constructs other than lists that require indentation, so it would be useful if this feature could be used for those as well. For example: https://spec.commonmark.org/0.31.2/#example-254

I have attached my patch as 0002 in the format-patch series, on top of your patch. It applies indentation only to the selected text, without limiting the target to list items.

Actions #4

Updated by Florian Walchshofer 24 days ago

Thanks Mizuki ISHIKAWA for your improvement!

I’ve tested it, and it works very well. I didn’t notice any downsides in my tests, even after trying several variations.
I agree that making this behavior generally available is a clear improvement.

Actions #5

Updated by Go MAEDA 24 days ago

I tested the behavior with the following two patches applied:

By limiting Tab indentation to cases where text is selected, the concern I raised in #note-1 about interfering with normal Tab-based field navigation has been resolved.

In addition, applying the second patch allows Tab/Shift+Tab indentation to work consistently on any selected text, not just list items, which makes the behavior simpler and more intuitive.

This behavior is also consistent with GitHub Issues, where selecting any text and pressing Tab performs indentation.

Actions #6

Updated by Go MAEDA 24 days ago

  • Target version set to 7.0.0

Setting the target version to 7.0.0.

Actions #7

Updated by Go MAEDA 17 days ago

I found a strange behavior with this patch.

When the last character in the selection is a line-ending newline character, pressing Tab or Shift+Tab may indent or unindent lines outside the selection.

Steps to reproduce:

1. Enter two lines of text.
2. Move the cursor to the beginning of the first line.
3. Hold Shift and press the down arrow key to select the entire first line.
4. Press the Tab key.

In this case, only the first line should be indented. However, both the first and second lines are indented.

Could you please check whether the patch handles this case correctly?

Actions #8

Updated by Mizuki ISHIKAWA 17 days ago

Go MAEDA wrote in #note-7:

I found a strange behavior with this patch.

When the last character in the selection is a line-ending newline character, pressing Tab or Shift+Tab may indent or unindent lines outside the selection.

Steps to reproduce:

1. Enter two lines of text.
2. Move the cursor to the beginning of the first line.
3. Hold Shift and press the down arrow key to select the entire first line.
4. Press the Tab key.

In this case, only the first line should be indented. However, both the first and second lines are indented.

Could you please check whether the patch handles this case correctly?

Thank you for the feedback. I have attached a patch that fixes the problem.

Actions #9

Updated by Go MAEDA 16 days ago

  • Subject changed from Support Tab/Shift+Tab indentation for CommonMark list items in wiki textarea to Support Tab/Shift+Tab indentation of selected textarea lines in CommonMark Markdown
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patches with slight changes in r24719. Thank you for your contribution.

With this change, users can indent or unindent selected lines in a textarea using Tab and Shift+Tab, making it easier to edit nested lists and and other multi-line Markdown structures.

Actions

Also available in: Atom PDF