This commit is contained in:
SunboX 2010-12-16 21:59:47 +01:00
commit 44907e90f4
15 changed files with 204 additions and 257 deletions

View file

@ -426,7 +426,7 @@ var Editor =function(renderer, doc) {
this.bgTokenizer.getState(cursor.row, function (lineState) {
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
var line = _self.doc.getLine(cursor.row),
lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
lineIndent = _self.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), _self.doc.getTabString());
var end = _self.doc.insert(cursor, text);
/* TODO: This shortcut is somehow broken

View file

@ -37,7 +37,7 @@
define(function(require, exports, module) {
var core = require("pilot/core");
var useragent = require("pilot/useragent");
var event = require("pilot/event");
var default_mac = require("ace/conf/keybindings/default_mac").bindings;
var default_win = require("ace/conf/keybindings/default_win").bindings;
@ -50,7 +50,7 @@ var KeyBinding = function(element, editor, config) {
var _self = this;
event.addKeyListener(element, function(e) {
// opera on mac swaps ctrl and meta keys
if (core.isOpera && core.isMac)
if (useragent.isOpera && useragent.isMac)
var hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
| (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
else
@ -145,7 +145,7 @@ var KeyBinding = function(element, editor, config) {
}
this.setConfig = function(config) {
this.config = config || (core.isMac
this.config = config || (useragent.isMac
? default_mac
: default_win);
if (typeof this.config.reverse == "undefined")

View file

@ -133,6 +133,15 @@ var Test = {
editor.indent();
assert.equal(["a12345", " b12345", "c12345"].join("\n"), doc.toString());
},
"test: no auto indent if cursor is before the {" : function() {
var doc = new Document("{", new JavaScriptMode());
var editor = new Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 0);
editor.onTextInput("\n");
assert.equal(["", "{"].join("\n"), doc.toString());
},
"test: outdent block" : function() {
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));