Merge pull request #1940 from ajaxorg/misc

Fix several small issues
This commit is contained in:
Lennart Kats 2014-05-01 19:17:36 +02:00
commit 12ef5f9f6b
11 changed files with 133 additions and 57 deletions

View file

@ -267,7 +267,7 @@ function workers(path) {
}).filter(function(x) { return !!x; }); }).filter(function(x) { return !!x; });
} }
function modeList() { function modeList() {
return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|_outdent|behaviour|completions/) return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/)
} }
function addSuffix(options) { function addSuffix(options) {
@ -280,7 +280,7 @@ function addSuffix(options) {
} }
} }
function getWriteFilters(options, projectType) { function getWriteFilters(options, projectType, main) {
var filters = [ var filters = [
copy.filter.moduleDefines, copy.filter.moduleDefines,
removeUseStrict, removeUseStrict,
@ -293,29 +293,30 @@ function getWriteFilters(options, projectType) {
if (options.noconflict) if (options.noconflict)
filters.push(namespace(options.ns)); filters.push(namespace(options.ns));
if (options.exportModule && projectType == "main" || projectType == "ext") {
filters.push(exportAce(options.ns, options.exportModule,
options.noconflict ? options.ns : "", projectType == "ext" && main));
}
if (options.compress) if (options.compress)
filters.push(copy.filter.uglifyjs); filters.push(copy.filter.uglifyjs);
// copy.filter.uglifyjs.options.ascii = true; doesn't work with some uglify.js versions // copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions
filters.push(function(text) { filters.push(function(text) {
var t1 = text.replace(/[\x80-\uffff]/g, function(c) { var text = text.replace(/[\x00-\x08\x0b\x0c\x0e\x19\x80-\uffff]/g, function(c) {
c = c.charCodeAt(0).toString(16); c = c.charCodeAt(0).toString(16);
if (c.length == 1)
return "\\x0" + c;
if (c.length == 2) if (c.length == 2)
return "\\x" + c; return "\\x" + c;
if (c.length == 3) if (c.length == 3)
c = "0" + c; return "\\u0" + c;
return "\\u" + c; return "\\u" + c;
}); });
return text; return text;
}); });
if (options.exportModule && projectType == "main") {
if (options.noconflict)
filters.push(exportAce(options.ns, options.exportModule, options.ns));
else
filters.push(exportAce(options.ns, options.exportModule));
}
return filters; return filters;
} }
@ -390,7 +391,7 @@ var buildAce = function(options) {
project: cloneProject(project), project: cloneProject(project),
require: [ 'ace/ext/' + ext ] require: [ 'ace/ext/' + ext ]
}], }],
filter: getWriteFilters(options, "ext"), filter: getWriteFilters(options, "ext", 'ace/ext/' + ext),
dest: targetDir + "/ext-" + ext + ".js" dest: targetDir + "/ext-" + ext + ".js"
}); });
}); });
@ -416,7 +417,7 @@ var buildAce = function(options) {
project.assumeAllFilesLoaded(); project.assumeAllFilesLoaded();
delete project.ignoredModules["ace/theme/textmate"]; delete project.ignoredModules["ace/theme/textmate"];
delete project.ignoredModules["ace/requirejs/text!ace/theme/textmate.css"]; delete project.ignoredModules["ace/requirejs/text!ace/theme/textmate.css"];
options.themes.forEach(function(theme) { options.themes.forEach(function(theme) {
console.log("theme " + theme); console.log("theme " + theme);
copy({ copy({
@ -428,7 +429,7 @@ var buildAce = function(options) {
dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".js" dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".js"
}); });
}); });
// generateThemesModule(options.themes); // generateThemesModule(options.themes);
console.log('# ace key bindings ---------'); console.log('# ace key bindings ---------');
@ -552,15 +553,6 @@ var detectTextModules = function(input, source) {
detectTextModules.onRead = true; detectTextModules.onRead = true;
copy.filter.addDefines = detectTextModules; copy.filter.addDefines = detectTextModules;
function generateThemesModule(themes) {
var themelist = [
'define(function(require, exports, module) {',
'\n\nmodule.exports.themes = ' + JSON.stringify(themes, null, ' '),
';\n\n});'
].join('');
fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8');
}
function inlineTextModules(text) { function inlineTextModules(text) {
var deps = []; var deps = [];
return text.replace(/, *['"]ace\/requirejs\/text!(.*?)['"]| require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, dep, call) { return text.replace(/, *['"]ace\/requirejs\/text!(.*?)['"]| require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, dep, call) {
@ -576,14 +568,38 @@ function inlineTextModules(text) {
}); });
call = textModules[dep]; call = textModules[dep];
// if (deps.length > 1)
// console.log(call.length)
if (call) if (call)
return " " + call; return " " + call;
} }
}); });
} }
var CommonJsProject = copy.createCommonJsProject({roots:[]}).constructor;
CommonJsProject.prototype.getCurrentModules = function() {
function isDep(child, parent) {
if (!modules[parent])
return false;
var deps = modules[parent].deps;
if (deps[child]) return true;
return Object.keys(deps).some(function(x) {
return isDep(child, x)
});
}
var depMap = {}, modules = this.currentModules;
return Object.keys(this.currentModules).map(function(moduleName) {
module = modules[moduleName];
module.id = moduleName;
module.isSpecial = !/define\(\'[^']*',/.test(module.source);
return module;
}).sort(function(a, b) {
if (a.isSpecial) return -1;
if (b.isSpecial) return 1;
if (isDep(a.id, b.id)) return -1;
if (isDep(b.id, a.id)) return 1;
return Object.keys(a.deps).length - Object.keys(b.deps).length || a.id.localeCompare(b.id)
});
};
// TODO: replace with project.clone once it is fixed in dryice // TODO: replace with project.clone once it is fixed in dryice
function cloneProject(project) { function cloneProject(project) {
var clone = copy.createCommonJsProject({ var clone = copy.createCommonJsProject({
@ -604,16 +620,12 @@ function cloneProject(project) {
} }
function copyFileSync(srcFile, destFile) { function copyFileSync(srcFile, destFile) {
var BUF_LENGTH = 64*1024, var BUF_LENGTH = 64*1024;
buf = new Buffer(BUF_LENGTH), var buf = new Buffer(BUF_LENGTH);
bytesRead = BUF_LENGTH, var bytesRead = BUF_LENGTH;
pos = 0, var pos = 0;
fdr = null, var fdr = fs.openSync(srcFile, 'r');
fdw = null; var fdw = fs.openSync(destFile, 'w');
fdr = fs.openSync(srcFile, 'r');
fdw = fs.openSync(destFile, 'w');
while (bytesRead === BUF_LENGTH) { while (bytesRead === BUF_LENGTH) {
bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos); bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
@ -650,23 +662,33 @@ function namespace(ns) {
}; };
} }
function exportAce(ns, module, requireBase) { function exportAce(ns, module, requireBase, extModule) {
requireBase = requireBase || "window"; requireBase = requireBase || "window";
module = module || "ace/ace"; module = module || "ace/ace";
return function(text) { return function(text) {
var template = function() { var template = function() {
(function() { (function() {
REQUIRE_NS.require(["MODULE"], function(a) { REQUIRE_NS.require(["MODULE"], function(a) {
a && a.config.init(); a && a.config.init(true);
if (!window.NS) if (!window.NS)
window.NS = {}; window.NS = a;
for (var key in a) if (a.hasOwnProperty(key)) for (var key in a) if (a.hasOwnProperty(key))
NS[key] = a[key]; NS[key] = a[key];
}); });
})(); })();
}; };
if (extModule) {
module = extModule;
template = function() {
(function() {
REQUIRE_NS.require(["MODULE"], function() {});
})();
};
}
text = text.replace(/function init\(packaged\) {/, "init(true);$&\n");
return (text + ";" + template return (text + ";" + template
.toString() .toString()
.replace(/MODULE/g, module) .replace(/MODULE/g, module)
@ -683,12 +705,21 @@ function updateModes() {
var source = fs.readFileSync(filepath, "utf8"); var source = fs.readFileSync(filepath, "utf8");
if (!/this.\$id\s*=\s*"/.test(source)) if (!/this.\$id\s*=\s*"/.test(source))
source = source.replace(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2'); source = source.replace(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2');
source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"'); source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"');
fs.writeFileSync(filepath, source, "utf8") fs.writeFileSync(filepath, source, "utf8")
}) })
} }
function generateThemesModule(themes) {
var themelist = [
'define(function(require, exports, module) {',
'\n\nmodule.exports.themes = ' + JSON.stringify(themes, null, ' '),
';\n\n});'
].join('');
fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8');
}
if (!module.parent) if (!module.parent)
main(process.argv); main(process.argv);
else else

View file

@ -80,6 +80,11 @@ exports.defaultCommands = [{
name: "alignCursors", name: "alignCursors",
exec: function(editor) { editor.alignCursors(); }, exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"} bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
}, {
name: "findAll",
exec: function(editor) { editor.findAll(); },
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
readonly: true
}]; }];
// commands active only in multiselect mode // commands active only in multiselect mode

View file

@ -149,12 +149,13 @@ exports.handler = {
if (!isHandled && hashId !== -1) if (!isHandled && hashId !== -1)
return; return;
return {command: "null", passEvent: !isHandled}; return {command: "null", passEvent: !isHandled};
} // if no modifier || shift: wait for input.
else if (key.length == 1 && (hashId === 0 || hashId == 4)) {
return {command: "null", passEvent: true};
} else if (key == "esc" && hashId === 0) { } else if (key == "esc" && hashId === 0) {
return {command: coreCommands.stop}; return {command: coreCommands.stop};
} }
// if no modifier || shift: wait for input.
else if (hashId === 0 || hashId == 4) {
return {command: "null", passEvent: true};
}
} else { } else {
if (key == "ctrl-w") { if (key == "ctrl-w") {
return {command: "removewordleft"}; return {command: "removewordleft"};

View file

@ -123,10 +123,12 @@ var actions = exports.actions = {
range.end.column++; range.end.column++;
var text = editor.session.getTextRange(range); var text = editor.session.getTextRange(range);
var toggled = text.toUpperCase(); var toggled = text.toUpperCase();
if (toggled == text) if (toggled != text)
editor.navigateRight();
else
editor.session.replace(range, toggled); editor.session.replace(range, toggled);
else if (text.toLowerCase() != text)
editor.session.replace(range, text.toLowerCase())
else
editor.navigateRight();
}, count || 1); }, count || 1);
} }
}, },
@ -164,6 +166,7 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions(); var options = editor.getLastSearchOptions();
options.backwards = false; options.backwards = false;
options.start = null;
editor.selection.moveCursorRight(); editor.selection.moveCursorRight();
editor.selection.clearSelection(); editor.selection.clearSelection();
@ -180,6 +183,7 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions(); var options = editor.getLastSearchOptions();
options.backwards = true; options.backwards = true;
options.start = null;
editor.findPrevious(options); editor.findPrevious(options);
ensureScrollMargin(editor); ensureScrollMargin(editor);
@ -340,6 +344,7 @@ var inputBuffer = exports.inputBuffer = {
currentCmd: null, currentCmd: null,
//currentMode: 0, //currentMode: 0,
currentCount: "", currentCount: "",
pendingCount: "",
status: "", status: "",
// Types // Types
@ -440,8 +445,9 @@ var inputBuffer = exports.inputBuffer = {
}, },
getCount: function() { getCount: function() {
var count = this.currentCount; var count = this.currentCount || this.pendingCount;
this.currentCount = ""; this.currentCount = "";
this.pendingCount = count;
return count && parseInt(count, 10); return count && parseInt(count, 10);
}, },
@ -497,7 +503,8 @@ var inputBuffer = exports.inputBuffer = {
else if (selectable) { else if (selectable) {
repeat(function() { repeat(function() {
run(motionObj.sel); run(motionObj.sel);
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param); operators[o.ch].fn(editor, editor.getSelectionRange(),
o.count, motionObj.param ? motionObj : param);
}, o.count || 1); }, o.count || 1);
} }
this.reset(); this.reset();
@ -517,6 +524,7 @@ var inputBuffer = exports.inputBuffer = {
this.operator = null; this.operator = null;
this.motion = null; this.motion = null;
this.currentCount = ""; this.currentCount = "";
this.pendingCount = "";
this.status = ""; this.status = "";
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
this.idle = true; this.idle = true;

View file

@ -350,6 +350,10 @@ module.exports = {
case "W": case "W":
editor.selection.selectAWord(); editor.selection.selectAWord();
break; break;
case ")":
case "}":
case "]":
param = editor.session.$brackets[param];
case "(": case "(":
case "{": case "{":
case "[": case "[":
@ -383,6 +387,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "f", param: param}; LAST_SEARCH_MOTION = {ch: "f", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -398,6 +403,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "F", param: param}; LAST_SEARCH_MOTION = {ch: "F", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -413,6 +419,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "t", param: param}; LAST_SEARCH_MOTION = {ch: "t", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -431,6 +438,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "T", param: param}; LAST_SEARCH_MOTION = {ch: "T", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -656,7 +664,8 @@ module.exports = {
pos.column = line.length; pos.column = line.length;
return pos; return pos;
} }
} },
isLine: true
}) })
}; };

View file

@ -115,6 +115,8 @@ module.exports = {
}, },
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
count = count || 1; count = count || 1;
if (param && param.isLine)
param = "y";
switch (param) { switch (param) {
case "y": case "y":
var pos = editor.getCursorPosition(); var pos = editor.getCursorPosition();

View file

@ -133,6 +133,15 @@ var Keys = (function() {
// workaround for firefox bug // workaround for firefox bug
ret[173] = '-'; ret[173] = '-';
(function() {
var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function(x) {
return i & ret.KEY_MODS[x];
}).join("-") + "-";
}
})();
(function() { (function() {
var mods = ["cmd", "ctrl", "alt", "shift"]; var mods = ["cmd", "ctrl", "alt", "shift"];

View file

@ -176,9 +176,12 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : ["punctuation.operator", "support.constant"], token : ["punctuation.operator", "support.constant"],
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/ regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, {
token : ["support.constant"],
regex : /that\b/
}, { }, {
token : ["storage.type", "punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/ regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
}, { }, {
token : keywordMapper, token : keywordMapper,
regex : identifierRe regex : identifierRe

View file

@ -36,10 +36,12 @@ var TextMode = require("./text").Mode;
var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules;
var Range = require("../range").Range; var Range = require("../range").Range;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var Mode = function() { var Mode = function() {
this.HighlightRules = ShHighlightRules; this.HighlightRules = ShHighlightRules;
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();
this.$behaviour = new CstyleBehaviour();
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);

View file

@ -69,7 +69,7 @@ var ShHighlightRules = function() {
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
var fileDescriptor = "(?:&" + intPart + ")"; var fileDescriptor = "(?:&" + intPart + ")";
var variableName = "[a-zA-Z][a-zA-Z0-9_]*"; var variableName = "[a-zA-Z_][a-zA-Z0-9_]*";
var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))"; var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))";
var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))"; var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";

View file

@ -578,8 +578,14 @@ var Editor = require("./editor").Editor;
this.findAll = function(needle, options, additive) { this.findAll = function(needle, options, additive) {
options = options || {}; options = options || {};
options.needle = needle || options.needle; options.needle = needle || options.needle;
if (options.needle == undefined) {
var range = this.selection.isEmpty()
? this.selection.getWordRange()
: this.selection.getRange();
options.needle = this.session.getTextRange(range);
}
this.$search.set(options); this.$search.set(options);
var ranges = this.$search.findAll(this.session); var ranges = this.$search.findAll(this.session);
if (!ranges.length) if (!ranges.length)
return 0; return 0;