Merge pull request #2459 from ajaxorg/c9

Sync with c9
This commit is contained in:
Ruben Daniels 2015-04-25 12:30:37 -07:00
commit 0dcb1281cd
12 changed files with 126 additions and 119 deletions

View file

@ -69,18 +69,14 @@ exports.iSearchCommands = [{
bindKey: {win: "Ctrl-F", mac: "Command-F"}, bindKey: {win: "Ctrl-F", mac: "Command-F"},
exec: function(iSearch) { exec: function(iSearch) {
iSearch.cancelSearch(true); iSearch.cancelSearch(true);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchForward", name: "searchForward",
bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"}, bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
exec: function(iSearch, options) { exec: function(iSearch, options) {
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
iSearch.next(options); iSearch.next(options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "searchBackward", name: "searchBackward",
bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"}, bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
@ -88,42 +84,30 @@ exports.iSearchCommands = [{
options.useCurrentOrPrevSearch = true; options.useCurrentOrPrevSearch = true;
options.backwards = true; options.backwards = true;
iSearch.next(options); iSearch.next(options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTerm", name: "extendSearchTerm",
exec: function(iSearch, string) { exec: function(iSearch, string) {
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "extendSearchTermSpace", name: "extendSearchTermSpace",
bindKey: "space", bindKey: "space",
exec: function(iSearch) { iSearch.addString(' '); }, exec: function(iSearch) { iSearch.addString(' '); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "shrinkSearchTerm", name: "shrinkSearchTerm",
bindKey: "backspace", bindKey: "backspace",
exec: function(iSearch) { exec: function(iSearch) {
iSearch.removeChar(); iSearch.removeChar();
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'confirmSearch', name: 'confirmSearch',
bindKey: 'return', bindKey: 'return',
exec: function(iSearch) { iSearch.deactivate(); }, exec: function(iSearch) { iSearch.deactivate(); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'cancelSearch', name: 'cancelSearch',
bindKey: 'esc|Ctrl-G', bindKey: 'esc|Ctrl-G',
exec: function(iSearch) { iSearch.deactivate(true); }, exec: function(iSearch) { iSearch.deactivate(true); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'occurisearch', name: 'occurisearch',
bindKey: 'Ctrl-O', bindKey: 'Ctrl-O',
@ -131,9 +115,7 @@ exports.iSearchCommands = [{
var options = oop.mixin({}, iSearch.$options); var options = oop.mixin({}, iSearch.$options);
iSearch.deactivate(); iSearch.deactivate();
occurStartCommand.exec(iSearch.$editor, options); occurStartCommand.exec(iSearch.$editor, options);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "yankNextWord", name: "yankNextWord",
bindKey: "Ctrl-w", bindKey: "Ctrl-w",
@ -142,9 +124,7 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }), range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
string = ed.session.getTextRange(range); string = ed.session.getTextRange(range);
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: "yankNextChar", name: "yankNextChar",
bindKey: "Ctrl-Alt-y", bindKey: "Ctrl-Alt-y",
@ -153,15 +133,11 @@ exports.iSearchCommands = [{
range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }), range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
string = ed.session.getTextRange(range); string = ed.session.getTextRange(range);
iSearch.addString(string); iSearch.addString(string);
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'recenterTopBottom', name: 'recenterTopBottom',
bindKey: 'Ctrl-l', bindKey: 'Ctrl-l',
exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }, exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'selectAllMatches', name: 'selectAllMatches',
bindKey: 'Ctrl-space', bindKey: 'Ctrl-space',
@ -173,18 +149,19 @@ exports.iSearchCommands = [{
return ranges.concat(ea ? ea : []); }, []) : []; return ranges.concat(ea ? ea : []); }, []) : [];
iSearch.deactivate(false); iSearch.deactivate(false);
ranges.forEach(ed.selection.addRange.bind(ed.selection)); ranges.forEach(ed.selection.addRange.bind(ed.selection));
}, }
readOnly: true,
isIncrementalSearchCommand: true
}, { }, {
name: 'searchAsRegExp', name: 'searchAsRegExp',
bindKey: 'Alt-r', bindKey: 'Alt-r',
exec: function(iSearch) { exec: function(iSearch) {
iSearch.convertNeedleToRegExp(); iSearch.convertNeedleToRegExp();
}, }
readOnly: true, }].map(function(cmd) {
isIncrementalSearchCommand: true cmd.readOnly = true;
}]; cmd.isIncrementalSearchCommand = true;
cmd.scrollIntoView = "animate-cursor";
return cmd;
});
function IncrementalSearchKeyboardHandler(iSearch) { function IncrementalSearchKeyboardHandler(iSearch) {
this.$iSearch = iSearch; this.$iSearch = iSearch;
@ -192,7 +169,7 @@ function IncrementalSearchKeyboardHandler(iSearch) {
oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
;(function() { (function() {
this.attach = function(editor) { this.attach = function(editor) {
var iSearch = this.$iSearch; var iSearch = this.$iSearch;
@ -201,15 +178,19 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (!e.command.isIncrementalSearchCommand) return undefined; if (!e.command.isIncrementalSearchCommand) return undefined;
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
return e.command.exec(iSearch, e.args || {}); var scrollTop = editor.session.getScrollTop();
var result = e.command.exec(iSearch, e.args || {});
editor.renderer.scrollCursorIntoView(null, 0.5);
editor.renderer.animateScrolling(scrollTop);
return result;
}); });
} };
this.detach = function(editor) { this.detach = function(editor) {
if (!this.$commandExecHandler) return; if (!this.$commandExecHandler) return;
editor.commands.removeEventListener('exec', this.$commandExecHandler); editor.commands.removeEventListener('exec', this.$commandExecHandler);
delete this.$commandExecHandler; delete this.$commandExecHandler;
} };
var handleKeyboard$super = this.handleKeyboard; var handleKeyboard$super = this.handleKeyboard;
this.handleKeyboard = function(data, hashId, key, keyCode) { this.handleKeyboard = function(data, hashId, key, keyCode) {
@ -222,7 +203,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
if (extendCmd) { return {command: extendCmd, args: key}; } if (extendCmd) { return {command: extendCmd, args: key}; }
} }
return {command: "null", passEvent: hashId == 0 || hashId == 4}; return {command: "null", passEvent: hashId == 0 || hashId == 4};
} };
}).call(IncrementalSearchKeyboardHandler.prototype); }).call(IncrementalSearchKeyboardHandler.prototype);

View file

@ -162,8 +162,12 @@ var Editor = function(renderer, session) {
var command = this.curOp.command; var command = this.curOp.command;
if (command.name && this.$blockScrolling > 0) if (command.name && this.$blockScrolling > 0)
this.$blockScrolling--; this.$blockScrolling--;
if (command && command.scrollIntoView) { var scrollIntoView = command && command.scrollIntoView;
switch (command.scrollIntoView) { if (scrollIntoView) {
switch (scrollIntoView) {
case "center-animate":
scrollIntoView = "animate";
/* fall through */
case "center": case "center":
this.renderer.scrollCursorIntoView(null, 0.5); this.renderer.scrollCursorIntoView(null, 0.5);
break; break;
@ -181,7 +185,7 @@ var Editor = function(renderer, session) {
default: default:
break; break;
} }
if (command.scrollIntoView == "animate") if (scrollIntoView == "animate")
this.renderer.animateScrolling(this.curOp.scrollTop); this.renderer.animateScrolling(this.curOp.scrollTop);
} }
@ -274,6 +278,10 @@ var Editor = function(renderer, session) {
this.setSession = function(session) { this.setSession = function(session) {
if (this.session == session) if (this.session == session)
return; return;
// make sure operationEnd events are not emitted to wrong session
if (this.curOp) this.endOperation();
this.curOp = {};
var oldSession = this.session; var oldSession = this.session;
if (oldSession) { if (oldSession) {
@ -373,6 +381,8 @@ var Editor = function(renderer, session) {
oldSession: oldSession oldSession: oldSession
}); });
this.curOp = null;
oldSession && oldSession._signal("changeEditor", {oldEditor: this}); oldSession && oldSession._signal("changeEditor", {oldEditor: this});
session && session._signal("changeEditor", {editor: this}); session && session._signal("changeEditor", {editor: this});
}; };

View file

@ -393,7 +393,7 @@ exports.updateCommands = function(editor, enabled) {
}; };
exports.isSupportedMode = function(modeId) { exports.isSupportedMode = function(modeId) {
return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs/.test(modeId); return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId);
}; };
var onChangeMode = function(e, target) { var onChangeMode = function(e, target) {

View file

@ -105,7 +105,7 @@ function objectToRegExp(obj) {
this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this)); this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
this.selectionFix(ed); this.selectionFix(ed);
this.statusMessage(true); this.statusMessage(true);
} };
this.deactivate = function(reset) { this.deactivate = function(reset) {
this.cancelSearch(reset); this.cancelSearch(reset);
@ -117,7 +117,7 @@ function objectToRegExp(obj) {
} }
ed.onPaste = this.$originalEditorOnPaste; ed.onPaste = this.$originalEditorOnPaste;
this.message(''); this.message('');
} };
this.selectionFix = function(editor) { this.selectionFix = function(editor) {
// Fix selection bug: When clicked inside the editor // Fix selection bug: When clicked inside the editor
@ -128,7 +128,7 @@ function objectToRegExp(obj) {
if (editor.selection.isEmpty() && !editor.session.$emacsMark) { if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
editor.clearSelection(); editor.clearSelection();
} }
} };
this.highlight = function(regexp) { this.highlight = function(regexp) {
var sess = this.$editor.session, var sess = this.$editor.session,
@ -136,7 +136,7 @@ function objectToRegExp(obj) {
new SearchHighlight(null, "ace_isearch-result", "text")); new SearchHighlight(null, "ace_isearch-result", "text"));
hl.setRegexp(regexp); hl.setRegexp(regexp);
sess._emit("changeBackMarker"); // force highlight layer redraw sess._emit("changeBackMarker"); // force highlight layer redraw
} };
this.cancelSearch = function(reset) { this.cancelSearch = function(reset) {
var e = this.$editor; var e = this.$editor;
@ -150,7 +150,7 @@ function objectToRegExp(obj) {
} }
this.highlight(null); this.highlight(null);
return Range.fromPoints(this.$currentPos, this.$currentPos); return Range.fromPoints(this.$currentPos, this.$currentPos);
} };
this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) { this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
if (!this.$editor) return null; if (!this.$editor) return null;
@ -163,7 +163,7 @@ function objectToRegExp(obj) {
if (options.needle.length === 0) { if (options.needle.length === 0) {
this.statusMessage(true); this.statusMessage(true);
return this.cancelSearch(true); return this.cancelSearch(true);
}; }
// try to find the next occurence and enable highlighting marker // try to find the next occurence and enable highlighting marker
options.start = this.$currentPos; options.start = this.$currentPos;
@ -176,13 +176,13 @@ function objectToRegExp(obj) {
this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end)); this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
if (moveToNext) this.$currentPos = found.end; if (moveToNext) this.$currentPos = found.end;
// highlight after cursor move, so selection works properly // highlight after cursor move, so selection works properly
this.highlight(options.re) this.highlight(options.re);
} }
this.statusMessage(found); this.statusMessage(found);
return found; return found;
} };
this.addString = function(s) { this.addString = function(s) {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
@ -192,7 +192,7 @@ function objectToRegExp(obj) {
reObj.expression += s; reObj.expression += s;
return objectToRegExp(reObj); return objectToRegExp(reObj);
}); });
} };
this.removeChar = function(c) { this.removeChar = function(c) {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
@ -202,7 +202,7 @@ function objectToRegExp(obj) {
reObj.expression = reObj.expression.substring(0, reObj.expression.length-1); reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
return objectToRegExp(reObj); return objectToRegExp(reObj);
}); });
} };
this.next = function(options) { this.next = function(options) {
// try to find the next occurence of whatever we have searched for // try to find the next occurence of whatever we have searched for
@ -215,29 +215,29 @@ function objectToRegExp(obj) {
return options.useCurrentOrPrevSearch && needle.length === 0 ? return options.useCurrentOrPrevSearch && needle.length === 0 ?
this.$prevNeedle || '' : needle; this.$prevNeedle || '' : needle;
}); });
} };
this.onMouseDown = function(evt) { this.onMouseDown = function(evt) {
// when mouse interaction happens then we quit incremental search // when mouse interaction happens then we quit incremental search
this.deactivate(); this.deactivate();
return true; return true;
} };
this.onPaste = function(text) { this.onPaste = function(text) {
this.addString(text); this.addString(text);
} };
this.convertNeedleToRegExp = function() { this.convertNeedleToRegExp = function() {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig'); return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
}); });
} };
this.convertNeedleToString = function() { this.convertNeedleToString = function() {
return this.highlightAndFindWithNeedle(false, function(needle) { return this.highlightAndFindWithNeedle(false, function(needle) {
return isRegExp(needle) ? regExpToObject(needle).expression : needle; return isRegExp(needle) ? regExpToObject(needle).expression : needle;
}); });
} };
this.statusMessage = function(found) { this.statusMessage = function(found) {
var options = this.$options, msg = ''; var options = this.$options, msg = '';
@ -245,7 +245,7 @@ function objectToRegExp(obj) {
msg += 'isearch: ' + options.needle; msg += 'isearch: ' + options.needle;
msg += found ? '' : ' (not found)'; msg += found ? '' : ' (not found)';
this.message(msg); this.message(msg);
} };
this.message = function(msg) { this.message = function(msg) {
if (this.$editor.showCommandLine) { if (this.$editor.showCommandLine) {
@ -254,7 +254,7 @@ function objectToRegExp(obj) {
} else { } else {
console.log(msg); console.log(msg);
} }
} };
}).call(IncrementalSearch.prototype); }).call(IncrementalSearch.prototype);

View file

@ -428,7 +428,7 @@ exports.emacsKeys = {
"M-;": "togglecomment", "M-;": "togglecomment",
"C-/|C-x u|S-C--|C-z": "undo", "C-/|C-x u|S-C--|C-z": "undo",
"S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo? "S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo?
// vertical editing // vertical editing
"C-x r": "selectRectangularRegion", "C-x r": "selectRectangularRegion",
"M-x": {command: "focusCommandLine", args: "M-x "} "M-x": {command: "focusCommandLine", args: "M-x "}
@ -483,7 +483,7 @@ exports.handler.addCommands({
// different. Deactivate the mark when setMark is run with active // different. Deactivate the mark when setMark is run with active
// mark // mark
if (transientMarkModeActive && (mark || !hasNoSelection)) { if (transientMarkModeActive && (mark || !hasNoSelection)) {
if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)}) if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)});
else editor.clearSelection(); else editor.clearSelection();
if (mark) editor.pushEmacsMark(null); if (mark) editor.pushEmacsMark(null);
return; return;

View file

@ -87,9 +87,12 @@ MultiHashHandler.prototype = HashHandler.prototype;
} }
}; };
this.bindKey = function(key, command, asDefault) { this.bindKey = function(key, command, position) {
if (typeof key == "object") if (typeof key == "object") {
if (position == undefined)
position = key.position;
key = key[this.platform]; key = key[this.platform];
}
if (!key) if (!key)
return; return;
if (typeof command == "function") if (typeof command == "function")
@ -110,11 +113,15 @@ MultiHashHandler.prototype = HashHandler.prototype;
} }
var binding = this.parseKeys(keyPart); var binding = this.parseKeys(keyPart);
var id = KEY_MODS[binding.hashId] + binding.key; var id = KEY_MODS[binding.hashId] + binding.key;
this._addCommandToBinding(chain + id, command, asDefault); this._addCommandToBinding(chain + id, command, position);
}, this); }, this);
}; };
this._addCommandToBinding = function(keyId, command, asDefault) { function getPosition(command) {
return typeof command == "object" && command.bindKey
&& command.bindKey.position || 0;
}
this._addCommandToBinding = function(keyId, command, position) {
var ckb = this.commandKeyBinding, i; var ckb = this.commandKeyBinding, i;
if (!command) { if (!command) {
delete ckb[keyId]; delete ckb[keyId];
@ -126,11 +133,21 @@ MultiHashHandler.prototype = HashHandler.prototype;
} else if ((i = ckb[keyId].indexOf(command)) != -1) { } else if ((i = ckb[keyId].indexOf(command)) != -1) {
ckb[keyId].splice(i, 1); ckb[keyId].splice(i, 1);
} }
if (asDefault || command.isDefault) if (typeof position != "number") {
ckb[keyId].unshift(command); if (position || command.isDefault)
else position = -100;
ckb[keyId].push(command); else
position = getPosition(command);
}
var commands = ckb[keyId];
for (i = 0; i < commands.length; i++) {
var other = commands[i];
var otherPos = getPosition(other);
if (otherPos > position)
break;
}
commands.splice(i, 0, command);
} }
}; };
@ -219,10 +236,18 @@ MultiHashHandler.prototype = HashHandler.prototype;
} }
} }
if (data.$keyChain && keyCode > 0) if (data.$keyChain) {
data.$keyChain = ""; if ((!hashId || hashId == 4) && keyString.length == 1)
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
else if (hashId == -1 || keyCode > 0)
data.$keyChain = ""; // reset keyChain
}
return {command: command}; return {command: command};
}; };
this.getStatusText = function(editor, data) {
return data.$keyChain || "";
};
}).call(HashHandler.prototype); }).call(HashHandler.prototype);

View file

@ -264,6 +264,7 @@ define(function(require, exports, module) {
} }
if (!this.ace.inVirtualSelectionMode) if (!this.ace.inVirtualSelectionMode)
this.ace.exitMultiSelectMode(); this.ace.exitMultiSelectMode();
this.ace.session.unfold({row: line, column: ch});
this.ace.selection.moveTo(line, ch); this.ace.selection.moveTo(line, ch);
}; };
this.getCursor = function(p) { this.getCursor = function(p) {
@ -737,10 +738,14 @@ CodeMirror.defineExtension = function(name, fn) {
CodeMirror.prototype[name] = fn; CodeMirror.prototype[name] = fn;
}; };
dom.importCssString(".normal-mode .ace_cursor{\ dom.importCssString(".normal-mode .ace_cursor{\
border: 0!important;\ border: 1px solid red;\
background-color: red;\ background-color: red;\
opacity: 0.5;\ opacity: 0.5;\
}.ace_dialog {\ }\
.normal-mode .ace_hidden-cursors .ace_cursor{\
background-color: transparent;\
}\
.ace_dialog {\
position: absolute;\ position: absolute;\
left: 0; right: 0;\ left: 0; right: 0;\
background: white;\ background: white;\
@ -766,23 +771,6 @@ dom.importCssString(".normal-mode .ace_cursor{\
font-family: monospace;\ font-family: monospace;\
}", "vimMode"); }", "vimMode");
(function() { (function() {
function dialogDiv(cm, template, bottom) {
var wrap = cm.ace.container;
var dialog;
dialog = wrap.appendChild(document.createElement("div"));
if (bottom)
dialog.className = "ace_dialog ace_dialog-bottom";
else
dialog.className = "ace_dialog ace_dialog-top";
if (typeof template == "string") {
dialog.innerHTML = template;
} else { // Assuming it's a detached DOM element.
dialog.appendChild(template);
}
return dialog;
}
function closeNotification(cm, newVal) { function closeNotification(cm, newVal) {
if (cm.state.currentNotificationClose) if (cm.state.currentNotificationClose)
cm.state.currentNotificationClose(); cm.state.currentNotificationClose();
@ -2204,6 +2192,8 @@ dom.importCssString(".normal-mode .ace_cursor{\
return; return;
} }
if (motionArgs.toJumplist) { if (motionArgs.toJumplist) {
if (!operator)
cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch
var jumpList = vimGlobalState.jumpList; var jumpList = vimGlobalState.jumpList;
// if the current motion is # or *, use cachedCursor // if the current motion is # or *, use cachedCursor
var cachedCursor = jumpList.cachedCursor; var cachedCursor = jumpList.cachedCursor;
@ -2890,6 +2880,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
var markPos = mark ? mark.find() : undefined; var markPos = mark ? mark.find() : undefined;
markPos = markPos ? markPos : cm.getCursor(); markPos = markPos ? markPos : cm.getCursor();
cm.setCursor(markPos); cm.setCursor(markPos);
cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch
}, },
scroll: function(cm, actionArgs, vim) { scroll: function(cm, actionArgs, vim) {
if (vim.visualMode) { if (vim.visualMode) {
@ -5940,7 +5931,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
}, true); }, true);
} }
return isHandled; return isHandled;
}; }
exports.CodeMirror = CodeMirror; exports.CodeMirror = CodeMirror;
var getVim = Vim.maybeInitVimState_; var getVim = Vim.maybeInitVimState_;
exports.handler = { exports.handler = {
@ -5954,9 +5945,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (!vim.insertMode) { if (!vim.insertMode) {
var isbackwards = !sel.cursor var isbackwards = !sel.cursor
? session.selection.isBackwards() || session.selection.isEmpty() ? session.selection.isBackwards() || session.selection.isEmpty()
: Range.comparePoints(sel.cursor, sel.start) <= 0 : Range.comparePoints(sel.cursor, sel.start) <= 0;
if (!isbackwards && left > w) if (!isbackwards && left > w)
left -= w left -= w;
} }
if (!vim.insertMode && vim.status) { if (!vim.insertMode && vim.status) {
h = h / 2; h = h / 2;
@ -6120,13 +6111,13 @@ dom.importCssString(".normal-mode .ace_cursor{\
}; };
var renderVirtualNumbers = { var renderVirtualNumbers = {
getText: function(session, row) { getText: function(session, row) {
return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + "" return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + "";
}, },
getWidth: function(session, lastLineNumber, config) { getWidth: function(session, lastLineNumber, config) {
return session.getLength().toString().length * config.characterWidth; return session.getLength().toString().length * config.characterWidth;
}, },
update: function(e, editor) { update: function(e, editor) {
editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER) editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER);
}, },
attach: function(editor) { attach: function(editor) {
editor.renderer.$gutterLayer.$renderer = this; editor.renderer.$gutterLayer.$renderer = this;
@ -6171,7 +6162,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (cm.ace.inVirtualSelectionMode) if (cm.ace.inVirtualSelectionMode)
cm.ace.on("beforeEndOperation", delayedExecAceCommand); cm.ace.on("beforeEndOperation", delayedExecAceCommand);
else else
delayedExecAceCommand(null, cm.ace) delayedExecAceCommand(null, cm.ace);
}; };
function delayedExecAceCommand(op, ace) { function delayedExecAceCommand(op, ace) {
ace.off("beforeEndOperation", delayedExecAceCommand); ace.off("beforeEndOperation", delayedExecAceCommand);

View file

@ -120,9 +120,9 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
this.setPolling = function(val) { this.setPolling = function(val) {
if (val) { if (val) {
this.$pollSizeChanges(); this.$pollSizeChanges();
} else { } else if (this.$pollSizeChangesTimer) {
if (this.$pollSizeChangesTimer) clearInterval(this.$pollSizeChangesTimer);
this.$pollSizeChangesTimer; this.$pollSizeChangesTimer = 0;
} }
}; };

View file

@ -244,7 +244,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
if (pressedKeys[keyCode] == 1) if (pressedKeys[keyCode] == 1)
ts = e.timeStamp; ts = e.timeStamp;
} else if (keyCode === 18 && hashId === 3 && location === 2) { } else if (keyCode === 18 && hashId === 3 && location === 2) {
var dt = e.timestamp - ts; var dt = e.timeStamp - ts;
if (dt < 50) if (dt < 50)
pressedKeys.altGr = true; pressedKeys.altGr = true;
} }

View file

@ -53,7 +53,7 @@ oop.inherits(Mode, TextMode);
this.blockComment = {start: "<!--", end: "-->"}; this.blockComment = {start: "<!--", end: "-->"};
this.createWorker = function(session) { this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker"); var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
worker.attachToDocument(session.getDocument()); worker.attachToDocument(session.getDocument());

View file

@ -82,11 +82,11 @@ function setSelection(editor, data) {
return isBackwards ? { return isBackwards ? {
start: end, start: end,
end: start, end: start,
isBackwards: true isBackwards: isBackwards
} : { } : {
start: start, start: start,
end: end, end: end,
isBackwards: true isBackwards: isBackwards
}; };
})); }));
} }
@ -223,19 +223,19 @@ module.exports = {
assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4"); assert.equal(editor.getValue(),"l1\nl1\nl2\nl2\nl3\nl3\nl4\nl4");
testSelection(editor, [[1,0],[3,0],[5,0],[7,0]]); testSelection(editor, [[1,0],[3,0],[5,0],[7,0]]);
setSelection(editor, [[1,2],[1,0,1,1],[3,0,3,1],[5,0,5,1],[7,0,7,1]]); setSelection(editor, [[1,2],[1,1,1,0],[3,0,3,1],[5,0,5,1],[7,0,7,1]]);
exec("copylinesdown"); exec("copylinesdown");
exec("copylinesup"); exec("copylinesup");
assert.equal(editor.getValue(),"l1\nl1\nl1\nl1\nl2\nl2\nl2\nl2\nl3\nl3\nl3\nl3\nl4\nl4\nl4\nl4"); assert.equal(editor.getValue(),"l1\nl1\nl1\nl1\nl2\nl2\nl2\nl2\nl3\nl3\nl3\nl3\nl4\nl4\nl4\nl4");
testSelection(editor, [[2,2],[2,0,2,1],[6,0,6,1],[10,0,10,1],[14,0,14,1]]); testSelection(editor, [[2,2],[2,1,2,0],[6,0,6,1],[10,0,10,1],[14,0,14,1]]);
exec("movelinesdown", 12); exec("movelinesdown", 12);
assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4\nl1\nl2\nl3\nl4"); assert.equal(editor.getValue(),"l1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4\nl1\nl2\nl3\nl4");
testSelection(editor, [[12,2],[12,0,12,1],[13,0,13,1],[14,0,14,1],[15,0,15,1]]); testSelection(editor, [[12,2],[12,1,12,0],[13,0,13,1],[14,0,14,1],[15,0,15,1]]);
exec("movelinesup", 12); exec("movelinesup", 12);
assert.equal(editor.getValue(),"l1\nl2\nl3\nl4\nl1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4"); assert.equal(editor.getValue(),"l1\nl2\nl3\nl4\nl1\nl1\nl1\nl2\nl2\nl2\nl3\nl3\nl3\nl4\nl4\nl4");
testSelection(editor, [[0,2],[0,0,0,1],[1,0,1,1],[2,0,2,1],[3,0,3,1]]); testSelection(editor, [[0,2],[0,1,0,0],[1,0,1,1],[2,0,2,1],[3,0,3,1]]);
}, },
"test multiselect fromJSON/toJSON": function() { "test multiselect fromJSON/toJSON": function() {

View file

@ -923,7 +923,7 @@ var Selection = function(session) {
this.toSingleRange(data[0]); this.toSingleRange(data[0]);
for (var i = data.length; i--; ) { for (var i = data.length; i--; ) {
var r = Range.fromPoints(data[i].start, data[i].end); var r = Range.fromPoints(data[i].start, data[i].end);
if (data.isBackwards) if (data[i].isBackwards)
r.cursor = r.start; r.cursor = r.start;
this.addRange(r, true); this.addRange(r, true);
} }