Page MenuHomePhabricator

Tab key behaviour differs from non-CodeMirror AbuseFilter editor
Closed, ResolvedPublic

Description

In the non-CodeMirror AbuseFilter editor, pressing the Tab key simply inserts a \t character (unless text is selected):

non-cm-tab-behaviour.gif (499×800 px, 50 KB)

In the CodeMirror editor, however, pressing Tab on a non-empty line inserts indentation, regardless of whether any text is selected:

cm-tab-behaviour.gif (410×800 px, 26 KB)

Acceptance criteria

  • Pressing the Tab key inserts \t when no text is selected.
  • Pressing the Tab key inserts indentation when text is selected.

Event Timeline

May I know what is the use case for inserting a tab character?

May I know what is the use case for inserting a tab character?

Sure, thanks for asking.

If we regex-search filters with the pattern \n[^\t]\t, we get quite a few matches. For example. I can find:

/* Sanitizing regular expressions (found in enwiki private filters) */
pattern := "(?x)
	keyword1
|	keyword2
|	keyword3
...
/* Operators at the beginning (found in jawiki private filters) */
action === "edit"
&	user_type === 'named'

...

&	/* Some comment for the block */
(
	user_groups contains ...
)

The issue is that in CodeMirror's AbuseFilter editor, we would have to copy-and-paste existing tab characters to preserve this formatting, which may negatively impact UX.

Okay, I get it now. I can work on this tomorrow.

Okay, I get it now. I can work on this tomorrow.

I appreciate it. There’s absolutely no rush.

Change #1276833 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] CodeMirror: pressing Tab to insert a tab character with no selection

https://gerrit.wikimedia.org/r/1276833

Change #1276833 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] CodeMirror: pressing Tab to insert a tab character with no selection

https://gerrit.wikimedia.org/r/1276833

Bhsd moved this task from Improvement to Done on the MediaWiki-extensions-CodeMirror board.