Page MenuHomePhabricator

CodeEditor extension should indent code using tabs instead of 4 spaces
Closed, ResolvedPublic

Description

As reported on [[mw:Thread:MediaWiki_talk:Gadget-CodeEditor.js/Tabs]] and on [[mw:Thread:MediaWiki talk:Gadget-CodeEditor.js/And where is the extension?]]
it would be useful if the code editor could indent the code using tabs instead of spaces.


Version: unspecified
Severity: major

Details

Reference
bz39616

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:07 AM
bzimport added a project: CodeEditor.
bzimport set Reference to bz39616.

The CodeEditor extension is using the Ace code editor (http://ace.ajax.org/).

Looking at the demo at http://ajaxorg.github.com/ace-builds/kitchen-sink.html, it supports a "use soft tab" option. It seems like CodeEditor utilizes this option without an easy way to override it.

I'm not sure we want literal tabs in textareas.

(In reply to comment #0)

As reported on [[mw:Thread:MediaWiki_talk:Gadget-CodeEditor.js/Tabs]] and on
[[mw:Thread:MediaWiki talk:Gadget-CodeEditor.js/And where is the extension?]]

This broken link should point to:
https://www.mediawiki.org/wiki/Thread:MediaWiki_talk:Gadget-CodeEditor.js/And_where_is_the_extension%3F

(In reply to comment #1)

I'm not sure we want literal tabs in textareas.

They are already there in lots of gadgets and user scripts. The current behavior breaks the indentation of existing scripts:
https://www.mediawiki.org/wiki/?diff=403115&oldid=403114
(and may also cause some dirt diffs)

I strongly oppose this request! Code editor sholdn't use tabs by default. Tabs in source code are always a bad idea since their width isn't uniform across platforms or even different applications.

If a functionality to preserve proper indentation for old files using tabs or an optional setting to enable tabs for indentation by default was used, that would be OK for me, though.

(In reply to comment #3)

I strongly oppose this request! Code editor sholdn't use tabs by default.

Well allow me to strongly oppose your opposition, then! Everything and anything meant for generating or editing code -- be it PHP, JS or CSS -- most definitely should use tabs.

Tabs are the official MediaWiki way of doing indentation (see the coding conventions manual on MediaWiki.org: https://www.mediawiki.org/wiki/Manual:Coding_conventions) and it definitely makes sense; tabs, from my perspective as a developer, make my life a lot easier as I have to hit an arrow key (for example) only once whereas with space-indented code, I'd have to hit the same key four times. Bleh!

Tabs
in source code are always a bad idea since their width isn't uniform across
platforms or even different applications.

It's unfortunate that some platforms have bad defaults, but I think we all can live with that. We most certainly have been able to live with it until now, and as far as I'm aware, nothing has essentially changed.

Additional evidence that this should be optional and not a fixed setting...

Maybe it could be optional, but tabs should *definitely* be the default for MediaWiki stuff.

This is now a bigger problem because the extension will be enabled ON EVERY WMF WIKI on August 29.

Change 80843 had a related patch set uploaded by Alex Monk:
Save real tabs

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

Change 80843 merged by jenkins-bot:
Save real tabs and allow configuration by users via JS hook

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

Can we compromise and use 3 spaces?