From a0bf81ed8f9e689056d30f27e69b04bdff147a41 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 2 Feb 2017 12:33:35 +0400 Subject: [PATCH] tweak automatic selection of mode --- .../ace/lib/ace/mode/json_highlight_rules.js | 15 ++++++++++++++- plugins/c9.ide.ace/ace.js | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/node_modules/ace/lib/ace/mode/json_highlight_rules.js b/node_modules/ace/lib/ace/mode/json_highlight_rules.js index 4bccaf18..661699f9 100644 --- a/node_modules/ace/lib/ace/mode/json_highlight_rules.js +++ b/node_modules/ace/lib/ace/mode/json_highlight_rules.js @@ -60,8 +60,12 @@ var JsonHighlightRules = function() { token : "invalid.illegal", // single quoted strings are not allowed regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }, { - token : "invalid.illegal", // comments are not allowed + token : "comment", // comments are not allowed, but who cares? regex : "\\/\\/.*$" + }, { + token : "comment.start", // comments are not allowed, but who cares? + regex : "\\/\\*", + next : "comment" }, { token : "paren.lparen", regex : "[[({]" @@ -89,6 +93,15 @@ var JsonHighlightRules = function() { regex : "", next : "start" } + ], + "comment" : [ + { + token : "comment.end", // comments are not allowed, but who cares? + regex : "\\*\\/", + next : "start" + }, { + defaultToken: "comment" + } ] }; diff --git a/plugins/c9.ide.ace/ace.js b/plugins/c9.ide.ace/ace.js index d12b88c9..64f38961 100644 --- a/plugins/c9.ide.ace/ace.js +++ b/plugins/c9.ide.ace/ace.js @@ -1477,9 +1477,12 @@ define(function(require, exports, module) { else if (/<\?xml/.test(firstLine)) { syntax = "xml"; } - else if (/^{/.test(firstLine)) { + else if (/^{\s*("|$)/.test(firstLine)) { syntax = "json"; } + else if (/^---$/.test(firstLine)) { + syntax = "yaml"; + } else if (/\.(bash|inputrc|profile|zsh)/.test(path)) { syntax = "sh"; }