Page MenuHomePhabricator

Support autocompletion in CodeEditor
Open, Needs TriagePublic

Description

CodeEditor should offer autocompletions like any other IDE or code editor tool.

The Ace editor used by CodeEditor supports live autocompletions behind a config flag.

Event Timeline

Change #1081516 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/CodeEditor@master] Enable live autocompletion in CodeEditor

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

How about a toggle button too? Not all users would like it. (T61924)

It's a universal feature of code editors. I don't think a toggle button is necessary here. Adding user preferences for everything is not sustainable. Besides, there's no easily recognisable icon for autocompletion.

Well, I know how to turn it on yet I haven't because I find it distracting. I just use Ctrl+Space if I want it.

It's a universal feature of code editors.

I can't think of a webpage with a code editor where autocompletion is on by default.

there's no easily recognisable icon for autocompletion

I think the lightbulb is pretty good.

Adding user preferences for everything is not sustainable

Then maybe implement T261118 first?

Change #1081516 merged by jenkins-bot:

[mediawiki/extensions/CodeEditor@master] Enable live autocompletion in CodeEditor

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

MusikAnimal subscribed.

Seems worthy of a User-notice, for future reference :)

It's worth noting that a few of the concerns here such as the inability to toggle autocompletion off, as well as T261118 will be resolved with T373711: Add support for Scribunto, JavaScript, CSS, JSON and Vue to CodeMirror 6. CodeMirror for non-wikitext is likely still months away from going live, but I thought I'd give a heads up anyway.

This is really annoying and I need a way to turn it off. I can't write code while things are popping up all the time, hijacking keys and covering other parts of the code.

You can disable it by pressing Ctrl + , and unticking Live Autocompletion

firefox_q95nGrlwWv.png (312×337 px, 15 KB)

It's a universal feature of code editors. I don't think a toggle button is necessary here. Adding user preferences for everything is not sustainable. Besides, there's no easily recognisable icon for autocompletion.

What's not a universal feature of code editors is mandatory autocomplete that recommends keywords from other programming languages. When I'm editing a Lua module, the editor should not be suggesting keywords from C and java:

Screenshot 2024-11-22 100733.png (156×365 px, 6 KB)

You can disable it by pressing Ctrl + , and unticking Live Autocompletion

How the heck is an end user supposed to figure that out without coming here and somehow finding this ticket? Why is there a hidden preferences menu hidden behind an unintuitive and undocumented keyboard shortcut instead of something standard like a gear icon? It's not like there's a lack of space on the toolbar for the code editor, which currently only has six buttons.

You can disable it by pressing Ctrl + , and unticking Live Autocompletion

How the heck is an end user supposed to figure that out without coming here and somehow finding this ticket? Why is there a hidden preferences menu hidden behind an unintuitive and undocumented keyboard shortcut instead of something standard like a gear icon? It's not like there's a lack of space on the toolbar for the code editor, which currently only has six buttons.

https://en.wikipedia.org/wiki/User:Nardog/CodeEditorAssist should probably just be added into CodeEditor directly.

I will include it in Tech News as this (unless anyone suggests something better in the next couple of hours):

The CodeEditor, which can be used in JavaScript, CSS, JSON, and Lua pages, now offers live autocompletions. Thanks to SD0001 for this improvement. The feature can be temporarily disabled by clicking Ctrl+, and un-selecting "Live Autocompletion".


You can disable it by pressing Ctrl + , and unticking Live Autocompletion

Unfortunately, this setting appears to be temporary (it does not persist through a page-reload). [Edit: Ah, but the script bd808 links to, appears to solve that too]

How the heck is an end user supposed to figure that out without coming here and somehow finding this ticket? Why is there a hidden preferences menu hidden behind an unintuitive and undocumented keyboard shortcut instead of something standard like a gear icon? It's not like there's a lack of space on the toolbar for the code editor, which currently only has six buttons.

Fair.

I was pleasantly surprised to see this - it's particularly helpful for the global reminder bot as I can easily check whether I've already added a wiki at https://meta.wikimedia.org/wiki/Global_reminder_bot/global (i.e, to prevent duplicates).