kopia lustrzana https://github.com/c9/core
editorTypes in editors.js
rodzic
442289c9f0
commit
5622295654
|
@ -1,6 +1,6 @@
|
|||
define(function(require, module, exports) {
|
||||
main.consumes = [
|
||||
"Plugin", "menus", "ui"
|
||||
"Plugin", "menus", "ui", "settings"
|
||||
];
|
||||
main.provides = ["editors"];
|
||||
return main;
|
||||
|
@ -9,6 +9,7 @@ define(function(require, module, exports) {
|
|||
var ui = imports.ui;
|
||||
var Plugin = imports.Plugin;
|
||||
var menus = imports.menus;
|
||||
var settings = imports.settings;
|
||||
|
||||
var extname = require("path").extname;
|
||||
var basename = require("path").basename;
|
||||
|
@ -69,6 +70,11 @@ define(function(require, module, exports) {
|
|||
function findEditorByFilename(fn) {
|
||||
var ext = extname(fn).substr(1).toLowerCase();
|
||||
var filename = basename(fn).toLowerCase();
|
||||
|
||||
// Check custom user settings first for preferred editor
|
||||
var customEditor = settings.get("user/tabs/editorTypes/@" + ext);
|
||||
if (customEditor) return customEditor;
|
||||
|
||||
var editor = fileExtensions[fn] && fileExtensions[fn][0]
|
||||
|| fileExtensions[filename] && fileExtensions[filename][0]
|
||||
|| fileExtensions[ext] && fileExtensions[ext][0]
|
||||
|
|
|
@ -1078,6 +1078,12 @@ define(function(require, module, exports) {
|
|||
// options.document.filter = true;
|
||||
options.editorType = type;
|
||||
|
||||
// Don't proceed if findEditorByFilename returned "none"
|
||||
if (editor === "none") {
|
||||
alert("Can't open " + basename(path) + ": file format unsupported");
|
||||
return callback(new Error("File not supported"));
|
||||
}
|
||||
|
||||
// Create the tab
|
||||
tab = createTab(options);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue