Page MenuHomePhabricator

Add autocompletion to CodeMirror extension
Open, LowPublicFeature

Description

List of all Magic words already loaded and used for highlighting.
It also can be used for auto completion.

Autocompletion also can be used for page names and Template data.

Related Objects

Event Timeline

Pastakhov raised the priority of this task from to Low.
Pastakhov updated the task description. (Show Details)
Pastakhov subscribed.

Hi Pastakhov,

I asked some users of our wiki. One was really interested. Myself is thinking that this feature is not needed as most wikis do have a set of templates which seldom get changed. Maybe this might useful for some hackers doing mostly template changes. Maybe when adding this feature then add also an option in the user preferences so users can disable (or enable, depend on the default) the autocompletion. ;-)

Regards,

Dennis

For link auto-completion, it could use something similar to Extension:LinkSuggest

There’s also a fairly simple gadget in Hebrew Wikipedia that does this for pages and templates. Code.

I'd like to see this. We use CodeMirror (and LinkSuggest), but the latter doesn't work with CodeMirror.

MediaWiki-extensions-CodeMirror is incompatible with MediaWiki-extensions-LinkSuggest.

Should that be a separate bug report? This feature request in this ticket might have a wider scope than fixing the MediaWiki-extensions-LinkSuggest incompatibility.

There’s also a fairly simple gadget in Hebrew Wikipedia that does this for pages and templates. Code.

Compatible with MediaWiki-extensions-CodeMirror?

If there is specific info why things are incompatible, a separate ticket is welcome indeed. See https://www.mediawiki.org/wiki/How_to_report_a_bug - thanks!

Izno changed the subtype of this task from "Task" to "Feature Request".Oct 5 2023, 1:48 AM
Bhsd subscribed.

Autocompletion for magic words and tag names will be relatively easier with the CodeMirror 6's language data interface.

Illustatrions of my attempts:

  1. Behavior switch

Screen Shot 2024-02-20 at 11.19.46 AM.png (331×589 px, 37 KB)

  1. Parser function

Screen Shot 2024-02-20 at 11.19.24 AM.png (324×585 px, 37 KB)

  1. Parser function (temporarily highlighted as template name)

Screen Shot 2024-02-20 at 11.18.49 AM.png (326×583 px, 30 KB)

  1. Tag name

Screen Shot 2024-02-21 at 10.09.04 AM.png (289×570 px, 19 KB)

@Bhsd Your demos look fantastic! The final image F42011955 is restricted, FYI.

My only feedback so far is maybe we shouldn't have autocompletion for {{, as I imagine most of the time editors would want a template and not a parser function. I can envision some being annoyed by the popup every time they type {{ in day-to-day editing. What do you think?

My only feedback so far is maybe we shouldn't have autocompletion for {{, as I imagine most of the time editors would want a template and not a parser function.

Sounds good! Then I will remove the parser function hints unless a # is typed.

My only feedback so far is maybe we shouldn't have autocompletion for {{, as I imagine most of the time editors would want a template and not a parser function.

Sounds good! Then I will remove the parser function hints unless a # is typed.

That, or now thinking it through more, perhaps it would autocomplete only if {{ is followed by a capital letter? That'd still probably confuse a lot of people, but for someone like me who always types templates lowercased, and parser functions uppercased (where applicable), it'd save me from having to check https://www.mediawiki.org/wiki/Help:Magic_words all the time!

Another idea is that maybe autocomplete for parser functions should be disabled entirely in content namespaces? Parser functions are rarely used there.

I suppose over-delivering on features is fine, rather than being overly cautious. We should probably put this behind a feature flag anyway until we tackle T359498.

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

[mediawiki/extensions/CodeMirror@master] CodeMirrorModeMediaWiki: autocompletion

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

Hey @Bhsd, awesome work on this. Is there any scope for also implementing autocompletion for page links? I appreciate that this is something that might be better served by the scope of T300618, but perhaps a lot of the work you've already done would make this significantly easier?

Is there any scope for also implementing autocompletion for page links?

Thanks for your suggestion! I can take a look at the code of Extension:LinkSuggest later.

Work in progress related to autocompletion for page links. The #invoke example requires additional changes in the MediaWiki StreamParser, so I'd better leave it for a future ticket if someone asks.

Screen Shot 2024-05-04 at 10.36.11 AM.png (334×1 px, 95 KB)

Screen Shot 2024-05-04 at 10.36.50 AM.png (338×928 px, 57 KB)

Screen Shot 2024-05-04 at 10.59.55 AM.png (331×1 px, 56 KB)

That looks awesome! The #invoke example looks good, but not the end of the world if it’s not doable as part of this ticket. Thanks for the hard work.

Sorry, I still find it challenging to support page name autocompletion without substantial changes in the tokenizer. Therefore, I will leave it as a future task, and just finish my patch with additional autocompletion for url protocols (attached).

Screen Shot 2024-05-11 at 11.19.12 AM.png (133×566 px, 11 KB)