Page MenuHomePhabricator

Enable completion of links, templates, tags, and magic words in VisualEditor source modes
Open, Needs TriagePublicFeature

Description

Feature summary
CodeMirror enables completions for [[ and {{ when in source mode in WikiEditor. However, because of the way CodeMirror integrates with VE source modes, this doesn't work in the 2017 editor or DiscussionTools source mode.

CleanShot 2026-07-16 at 16.00.35@2x.png (950×408 px, 94 KB)

CodeMirror's hands-off implementation with VE is for complicated reasons, and VE already has a completion system (see: \ and @) that could be used.

This is less important for the VE source modes than it was for WikiEditor because in the VE modes the keyboard shortcuts and toolbar actions are available to trigger the relevant inspector/dialog.

Codemirror also offers completions on < and __ for tags and magic words. These are less-available from VE shortcuts, because there's a fair few that we don't have specific integrations for.

Use case(s):
Quickly inserting links and templates.

Benefits:
Lets users avoid typos and quickly add links without needing to search elsewhere.

Tech/news

DiscussionTools' source mode and the 2017 wikitext editor now offer autocomplete for links ([[), templates ({{), HTML and parser tags (<), and magic words (__)."

Event Timeline

Change #1311570 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] Wikitext completion actions for links and templates

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

Change #1311572 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/DiscussionTools@master] ui.TagCompletionAction: in source mode offer to complete common HTML

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

Test wiki created on Patch demo by DLynch (WMF) using patch(es) linked to this task:
https://538d6868b8.catalyst.wmcloud.org/w/

Change #1311879 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] MWTagCompletionAction: in source mode offer to complete common HTML tags

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

Change #1311572 abandoned by DLynch:

[mediawiki/extensions/DiscussionTools@master] ui.TagCompletionAction: in source mode offer to complete common HTML

Reason:

In favor of I096b4bdac2af9daa7dc4feeae69e495e6eef15da inside VisualEditor

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

DLynch renamed this task from Enable completion of links and templates in VisualEditor source modes to Enable completion of links, templates, tags, and magic words in VisualEditor source modes.Jul 17 2026, 5:12 PM
DLynch updated the task description. (Show Details)

Change #1311882 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] MWMagicWordCompletionAction: in source mode offer to complete magic words

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

@DLynch responding to user notice. How should we word this for tech news?

Test wiki created on Patch demo by DLynch (WMF) using patch(es) linked to this task:
https://395d77c269.catalyst.wmcloud.org/w/

@STei-WMF how about: "DiscussionTools' source mode and the 2017 wikitext editor will now offer autocomplete for links ([[), templates ({{), HTML and parser tags (<), and magic words (__)."

Here's a gif showing off most of it:

CleanShot 2026-07-17 at 14.26.17.gif (800×501 px, 2 MB)

Test wiki on Patch demo by DLynch (WMF) using patch(es) linked to this task was deleted:

https://538d6868b8.catalyst.wmcloud.org/w/

Change #1311570 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Wikitext completion actions for links and templates

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

Change #1311879 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] MWTagCompletionAction: in source mode offer to complete common HTML tags

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

Change #1311882 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] MWMagicWordCompletionAction: in source mode offer to complete magic words

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

Change #1312478 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] Magic word autocomplete: Sort entries, and show more

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

Change #1312506 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] TagCompletion: Only show suggestions after input provided

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

Change #1312507 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/VisualEditor@master] TitleCompletionAction: Use TitleWidget logic for search

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

Change #1312478 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Magic word autocomplete: Sort entries, and show more

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

Change #1312506 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] TagCompletion: Only show suggestions after input provided

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

Great addition, thanks! One thing I would add is that the autocompletion should be closed if a | or a closing ] or } is typed since autocompletion is no longer useful at that point. That is how the autocompletion on the legacy WikiEditor seems to work.

image.png (715×413 px, 26 KB)

image.png (668×397 px, 29 KB)

@Samoasambia Good point. It's currently just applying the default completion-widget behavior, which is to close when there's no remaining matches (the "show your input as an option" behavior doesn't count as a match) and you press space again. I can make a quick patch to reflect that we know more about when there's no possible future completions for these specific inputs...

Change #1314855 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] MWTitleCompletionAction: abandon as soon as a non-link character is used

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

Change #1314855 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] MWTitleCompletionAction: abandon as soon as a non-link character is used

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

@Samoasambia Okay, once that's deployed the link/template suggestions will abandon suggesting as soon as you've typed }, ], or |. 👍🏻

Change #1320240 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/VisualEditor@master] MWTemplateCompletionAction: reuse the template dialog's search

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

Change #1312507 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] TitleCompletionAction: Use TitleWidget logic for search

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

Change #1320240 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] MWTemplateCompletionAction: reuse the template dialog's search

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

Test wiki on Patch demo by DLynch (WMF) using patch(es) linked to this task was deleted:

https://395d77c269.catalyst.wmcloud.org/w/