Page MenuHomePhabricator

Add autocompletion to CodeMirror extension
Closed, ResolvedPublicFeature

Assigned To
Authored By
Pastakhov
Apr 5 2015, 5:59 AM
Referenced Files
F52044049: Screen Shot 2024-05-11 at 11.19.12 AM.png
May 11 2024, 3:20 AM
F50076124: Screen Shot 2024-05-04 at 10.59.55 AM.png
May 4 2024, 3:01 AM
F50073789: Screen Shot 2024-05-04 at 10.37.54 AM.png
May 4 2024, 2:45 AM
F50073786: Screen Shot 2024-05-04 at 10.36.50 AM.png
May 4 2024, 2:45 AM
F50073788: Screen Shot 2024-05-04 at 10.36.11 AM.png
May 4 2024, 2:45 AM
F42011955: Screen Shot 2024-02-21 at 10.09.04 AM.png
Feb 21 2024, 2:10 AM
F41993075: Screen Shot 2024-02-20 at 11.18.49 AM.png
Feb 20 2024, 3:49 AM
F41993076: Screen Shot 2024-02-20 at 11.19.24 AM.png
Feb 20 2024, 3:49 AM
Tokens
"Burninate" token, awarded by Jack_who_built_the_house.

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

StatusSubtypeAssignedTask
OpenFeatureNone
ResolvedFeatureBhsd
In ProgressGoalNone
ResolvedFeatureMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedMusikAnimal
ResolvedBhsd
OpenBUG REPORTNone
ResolvedMusikAnimal
In ProgressMusikAnimal
OpenTheresNoTime
OpenNone
OpenMusikAnimal
OpenBUG REPORTNone
OpenMusikAnimal
ResolvedBUG REPORTMusikAnimal
OpenBUG REPORTNone
ResolvedBUG REPORTMusikAnimal
OpenNone
ResolvedMusikAnimal
ResolvedMusikAnimal
OpenNone
OpenFeatureNone
Resolvedawight
ResolvedLena_WMDE
ResolvedLena_WMDE
OpenFeatureNone
ResolvedMusikAnimal
ResolvedBhsd
In ProgressMusikAnimal
ResolvedMusikAnimal

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)

Change #1024990 merged by jenkins-bot:

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

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

There may be some follow-ups such as autocompletion for templates and page names, but those should be raised as separate tasks. I think we can declare this task resolved. Thanks a million to @Bhsd for their brilliant work! :)

This is really annoying, how do I turn it off?

This is really annoying, how do I turn it off?

You probably mean the change in T377663: Support autocompletion in CodeEditor. CodeMirror 6 isn’t available anywhere other than mediawiki.org yet and I don't think autocompletion is there at all.

This is really annoying, how do I turn it off?

You probably mean the change in T377663: Support autocompletion in CodeEditor. CodeMirror 6 isn’t available anywhere other than mediawiki.org yet and I don't think autocompletion is there at all.

Thanks. The names are really confusing. :/