-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Make mode string in statusbar more presentable #1923
Conversation
slash = s.indexOf("/"); | ||
|
||
if (slash !== -1) { | ||
s = s.substr(0, slash); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still want to keep those modes that have mime type like text/x-xxx to be X-xxx? eg. text/x-c++src or x-java or x-csharp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. I also stripped "x-" from beginning.
Note that CodeMirror sends a mode of "text/plain" for most files, so this doesn't impact most files used on web sites.
Done with initial review. |
Changes. Pushed. |
s = s.substr(5); | ||
} else if (s.indexOf("application/") === 0) { | ||
s = s.substr(12); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can replace the entire if statement (and else if) with s = s.replace(/^(text\/|application\/)/, "");
Then you don't need those hard-coded numbers to extract sub strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be slower since it does a string replacement every time if a change was made or not, but I went ahead and made this change because the code is a bit cleaner :)
Done reviewing the additional changes. |
s = s.toLowerCase(); | ||
|
||
// Handle special cases | ||
if (s === "javascript") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a special case for XMLfiles. Currently, it shows up as Xml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do PHP and LESS have a similar problem?
Maybe we should just do a quick run-through of all the "officially" supported filetypes in EditorUtils and make sure the output is sane for all those cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No for PHP since it shows up as HTML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that will change once #1825 is fixed though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterflynn .less files now show up as "Less". Let me know if you think this should be "LESS".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's normally written in all caps (see http://lesscss.org/), so that would be ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added special cases for LESS and PHP.
Note to see PHP, you need to add a PHP block of code something like , make sure file is in the working set, place the IP inside the PHP block, switch to another file and then switch back.
Done with changes for code review comments. |
Make mode string in statusbar more presentable
This is for #1826
This fixes exception with many modes such as JSON. Mode can be either a string or an Object with a name property, but it was assumed to be a string.
Handled as a special case: JavaScript, HTML, CSS. Any others we should handle?
For remaining cases, we strip "/" and everything after it, and then capitalize what's left. Most of these are simply "Text".