merge
This commit is contained in:
commit
8f0d0a555f
22 changed files with 570 additions and 497 deletions
9
.gitmodules
vendored
9
.gitmodules
vendored
|
|
@ -10,3 +10,12 @@
|
||||||
[submodule "support/node-o3-xml"]
|
[submodule "support/node-o3-xml"]
|
||||||
path = support/node-o3-xml
|
path = support/node-o3-xml
|
||||||
url = git://github.com/ajaxorg/node-o3-xml.git
|
url = git://github.com/ajaxorg/node-o3-xml.git
|
||||||
|
[submodule "support/async"]
|
||||||
|
path = support/async
|
||||||
|
url = git://github.com/fjakobs/async.js.git
|
||||||
|
[submodule "support/jsdom"]
|
||||||
|
path = support/jsdom
|
||||||
|
url = git://github.com/tmpvar/jsdom.git
|
||||||
|
[submodule "support/node-htmlparser"]
|
||||||
|
path = support/node-htmlparser
|
||||||
|
url = git://github.com/tautologistics/node-htmlparser.git
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
ACE (Ajax.org Code Ediror)
|
ACE (Ajax.org Code Editor)
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
ACE is a standalone code editor written in JavaScript. It can be easily embedded in any web page and JavaScript application. It is currently used as the editor component of the [Cloud9 IDE](http://cloud9ide.com).
|
ACE is a standalone code editor written in JavaScript. It can be easily embedded in any web page and JavaScript application. It is currently used as the editor component of the [Cloud9 IDE](http://cloud9ide.com).
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ exports.bindings = {
|
||||||
"godown": "Down",
|
"godown": "Down",
|
||||||
"selectwordleft": "Ctrl-Shift-Left",
|
"selectwordleft": "Ctrl-Shift-Left",
|
||||||
"gotowordleft": "Ctrl-Left",
|
"gotowordleft": "Ctrl-Left",
|
||||||
"selecttolinestart": "Ctrl-Shift-Left",
|
"selecttolinestart": "Alt-Shift-Left",
|
||||||
"gotolinestart": "Alt-Left|Home",
|
"gotolinestart": "Alt-Left|Home",
|
||||||
"selectleft": "Shift-Left",
|
"selectleft": "Shift-Left",
|
||||||
"gotoleft": "Left",
|
"gotoleft": "Left",
|
||||||
"selectwordright": "Ctrl-Shift-Right",
|
"selectwordright": "Ctrl-Shift-Right",
|
||||||
"gotowordright": "Ctrl-Right",
|
"gotowordright": "Ctrl-Right",
|
||||||
"selecttolineend": "Ctrl-Shift-Right",
|
"selecttolineend": "Alt-Shift-Right",
|
||||||
"gotolineend": "Alt-Right|End",
|
"gotolineend": "Alt-Right|End",
|
||||||
"selectright": "Shift-Right",
|
"selectright": "Shift-Right",
|
||||||
"gotoright": "Right",
|
"gotoright": "Right",
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ var TextMode = require("ace/mode/text").Text;
|
||||||
var Range = require("ace/range").Range;
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var Document = function(text, mode) {
|
var Document = function(text, mode) {
|
||||||
|
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.lines = [];
|
this.lines = [];
|
||||||
this.selection = new Selection(this);
|
this.selection = new Selection(this);
|
||||||
|
|
@ -569,9 +570,10 @@ var Document = function(text, mode) {
|
||||||
var row = this.getLine(firstRow).substring(0, range.start.column)
|
var row = this.getLine(firstRow).substring(0, range.start.column)
|
||||||
+ this.getLine(lastRow).substring(range.end.column);
|
+ this.getLine(lastRow).substring(range.end.column);
|
||||||
|
|
||||||
this.lines.splice(firstRow, lastRow - firstRow + 1, row);
|
if (row != "")
|
||||||
|
this.lines.splice(firstRow, lastRow - firstRow + 1, row);
|
||||||
|
else
|
||||||
|
this.lines.splice(firstRow, lastRow - firstRow + 1, "");
|
||||||
return range.start;
|
return range.start;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -664,7 +666,7 @@ var Document = function(text, mode) {
|
||||||
var removed = this.lines.slice(firstRow, lastRow + 1);
|
var removed = this.lines.slice(firstRow, lastRow + 1);
|
||||||
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
|
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
|
||||||
this.$insertLines(firstRow - 1, removed);
|
this.$insertLines(firstRow - 1, removed);
|
||||||
|
|
||||||
this.fireChangeEvent(firstRow - 1, lastRow);
|
this.fireChangeEvent(firstRow - 1, lastRow);
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ var Editor =function(renderer, doc) {
|
||||||
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
|
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
|
||||||
var line = _self.doc.getLine(cursor.row),
|
var line = _self.doc.getLine(cursor.row),
|
||||||
lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
||||||
var end = _self.doc.insert(cursor, text);
|
var end = _self.doc.insert(cursor, text);
|
||||||
|
|
||||||
/* TODO: This shortcut is somehow broken
|
/* TODO: This shortcut is somehow broken
|
||||||
if (!shouldOutdent && line != _self.doc.getLine(row) && text != "\n") {
|
if (!shouldOutdent && line != _self.doc.getLine(row) && text != "\n") {
|
||||||
|
|
@ -457,6 +457,7 @@ var Editor =function(renderer, doc) {
|
||||||
if (/[^\s]$/.test(line))
|
if (/[^\s]$/.test(line))
|
||||||
minIndent = Math.min(indent, minIndent);
|
minIndent = Math.min(indent, minIndent);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||||
var outdent = minIndent;
|
var outdent = minIndent;
|
||||||
|
|
||||||
|
|
@ -602,19 +603,22 @@ var Editor =function(renderer, doc) {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var range = this.getSelectionRange();
|
var doc = this.doc,
|
||||||
|
range = this.getSelectionRange();
|
||||||
|
|
||||||
if (range.start.row < range.end.row ||
|
if (range.start.row < range.end.row ||
|
||||||
range.start.column < range.end.column) {
|
range.start.column < range.end.column) {
|
||||||
var count = this.doc.indentRows(this.getSelectionRange(), "\t");
|
var count = doc.indentRows(this.getSelectionRange(), "\t");
|
||||||
|
|
||||||
this.selection.shiftSelection(count);
|
this.selection.shiftSelection(count);
|
||||||
} else {
|
} else {
|
||||||
var indentString;
|
var indentString;
|
||||||
|
|
||||||
if (this.doc.getUseSoftTabs()) {
|
if (this.doc.getUseSoftTabs()) {
|
||||||
var size = this.doc.getTabSize(),
|
var size = doc.getTabSize(),
|
||||||
count = (size - this.getCursorPosition().column % size);
|
position = this.getCursorPosition(),
|
||||||
|
column = doc.documentToScreenColumn(position.row, position.column),
|
||||||
|
count = (size - column % size);
|
||||||
|
|
||||||
indentString = lang.stringRepeat(" ", count);
|
indentString = lang.stringRepeat(" ", count);
|
||||||
} else
|
} else
|
||||||
|
|
@ -623,7 +627,7 @@ var Editor =function(renderer, doc) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.blockOutdent = function(indentString) {
|
this.blockOutdent = function() {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -956,13 +960,14 @@ var Editor =function(renderer, doc) {
|
||||||
if (options) {
|
if (options) {
|
||||||
this.$search.set(options);
|
this.$search.set(options);
|
||||||
}
|
}
|
||||||
this.clearSelection();
|
|
||||||
this.selection.moveCursorTo(0, 0);
|
|
||||||
|
|
||||||
var ranges = this.$search.findAll(this.doc);
|
var ranges = this.$search.findAll(this.doc);
|
||||||
if (!ranges.length)
|
if (!ranges.length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
this.clearSelection();
|
||||||
|
this.selection.moveCursorTo(0, 0);
|
||||||
|
|
||||||
for (var i = ranges.length - 1; i >= 0; --i)
|
for (var i = ranges.length - 1; i >= 0; --i)
|
||||||
this.$tryReplace(ranges[i], replacement);
|
this.$tryReplace(ranges[i], replacement);
|
||||||
if (ranges[0] !== null)
|
if (ranges[0] !== null)
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
this.updateLines = function(layerConfig, firstRow, lastRow) {
|
this.updateLines = function(layerConfig, firstRow, lastRow) {
|
||||||
this.$computeTabString();
|
this.$computeTabString();
|
||||||
|
this.config = layerConfig;
|
||||||
|
|
||||||
var first = Math.max(firstRow, layerConfig.firstRow);
|
var first = Math.max(firstRow, layerConfig.firstRow);
|
||||||
var last = Math.min(lastRow, layerConfig.lastRow);
|
var last = Math.min(lastRow, layerConfig.lastRow);
|
||||||
|
|
@ -234,6 +235,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
this.update = function(config) {
|
this.update = function(config) {
|
||||||
this.$computeTabString();
|
this.$computeTabString();
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
var html = [];
|
var html = [];
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ oop.inherits(JavaScript, TextMode);
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
return indent;
|
return indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == "start") {
|
if (state == "start") {
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
@ -107,7 +107,12 @@ oop.inherits(JavaScript, TextMode);
|
||||||
indent += " ";
|
indent += " ";
|
||||||
}
|
}
|
||||||
indent += "* ";
|
indent += "* ";
|
||||||
}
|
}{
|
||||||
|
if (match[1]) {
|
||||||
|
indent += " ";
|
||||||
|
}
|
||||||
|
indent += "* ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return indent;
|
return indent;
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,32 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([], function() {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
window.assertPosition = function(row, column, cursor) {
|
var assert = require("assert");
|
||||||
assertEquals(row, cursor.row);
|
|
||||||
assertEquals(column, cursor.column);
|
assert.position = function(cursor, row, column) {
|
||||||
|
assert.equal(cursor.row, row);
|
||||||
|
assert.equal(cursor.column, column);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.assertRange = function(startRow, startColumn, endRow, endColumn, range) {
|
assert.range = function(range, startRow, startColumn, endRow, endColumn) {
|
||||||
assertPosition(startRow, startColumn, range.start);
|
assert.position(range.start, startRow, startColumn);
|
||||||
assertPosition(endRow, endColumn, range.end);
|
assert.position(range.end, endRow, endColumn);
|
||||||
};
|
};
|
||||||
|
|
||||||
window.assertJsonEquals = function(expectedJson, foundJson) {
|
assert.true = function(value) {
|
||||||
assertEquals(JSON.stringify(expectedJson), JSON.stringify(foundJson));
|
assert.equal(value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.false = function(value) {
|
||||||
|
assert.equal(value, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.jsonEquals = function(foundJson, expectedJson) {
|
||||||
|
assert.equal(JSON.stringify(foundJson), JSON.stringify(expectedJson));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = assert;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -35,35 +35,37 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document",
|
|
||||||
"ace/Editor",
|
|
||||||
"ace/mode/Text",
|
|
||||||
"ace/mode/JavaScript",
|
|
||||||
"ace/test/MockRenderer"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
Editor,
|
|
||||||
textMod,
|
|
||||||
jsMod,
|
|
||||||
MockRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
var TextMode = textMod.Text;
|
var dom = require('jsdom/level2/html').dom.level2.html;
|
||||||
var JavaScriptMode = jsMod.JavaScript;
|
var browser = require('jsdom/browser/index').windowAugmentation(dom);
|
||||||
var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
|
||||||
|
global.document = browser.document;
|
||||||
|
global.window = browser.window;
|
||||||
|
global.self = browser.self;
|
||||||
|
global.navigator = browser.navigator;
|
||||||
|
global.location = browser.location;
|
||||||
|
|
||||||
|
var Document = require("../document"),
|
||||||
|
Editor = require("../editor"),
|
||||||
|
Text = require("../mode/text"),
|
||||||
|
JavaScriptMode = require("../mode/javascript"),
|
||||||
|
MockRenderer = require("./mockrenderer"),
|
||||||
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.doc1 = new Document(["abc", "def"].join("\n"));
|
this.doc1 = new Document(["abc", "def"].join("\n"));
|
||||||
this.doc2 = new Document(["ghi", "jkl"].join("\n"));
|
this.doc2 = new Document(["ghi", "jkl"].join("\n"));
|
||||||
this.editor = new Editor(new MockRenderer());
|
this.editor = new Editor(new MockRenderer());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: change document" : function() {
|
"test: change document" : function() {
|
||||||
this.editor.setDocument(this.doc1);
|
this.editor.setDocument(this.doc1);
|
||||||
assertEquals(this.doc1, this.editor.getDocument());
|
assert.equal(this.editor.getDocument(), this.doc1);
|
||||||
|
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
assertEquals(this.doc2, this.editor.getDocument());
|
assert.equal(this.editor.getDocument(), this.doc2);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: only changes to the new document should have effect" : function() {
|
"test: only changes to the new document should have effect" : function() {
|
||||||
|
|
@ -76,10 +78,10 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
|
|
||||||
this.doc1.duplicateLines(0, 0);
|
this.doc1.duplicateLines(0, 0);
|
||||||
assertFalse(called);
|
assert.false(called);
|
||||||
|
|
||||||
this.doc2.duplicateLines(0, 0);
|
this.doc2.duplicateLines(0, 0);
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should use cursor of new document" : function() {
|
"test: should use cursor of new document" : function() {
|
||||||
|
|
@ -87,10 +89,10 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
this.doc2.getSelection().moveCursorTo(1, 0);
|
this.doc2.getSelection().moveCursorTo(1, 0);
|
||||||
|
|
||||||
this.editor.setDocument(this.doc1);
|
this.editor.setDocument(this.doc1);
|
||||||
assertPosition(0, 1, this.editor.getCursorPosition());
|
assert.position(this.editor.getCursorPosition(), 0, 1);
|
||||||
|
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
assertPosition(1, 0, this.editor.getCursorPosition());
|
assert.position(this.editor.getCursorPosition(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: only changing the cursor of the new doc should not have an effect" : function() {
|
"test: only changing the cursor of the new doc should not have an effect" : function() {
|
||||||
|
|
@ -100,16 +102,16 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
|
|
||||||
this.editor.setDocument(this.doc1);
|
this.editor.setDocument(this.doc1);
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
assertPosition(0, 0, this.editor.getCursorPosition());
|
assert.position(this.editor.getCursorPosition(), 0, 0);
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
this.doc1.getSelection().moveCursorTo(0, 1);
|
this.doc1.getSelection().moveCursorTo(0, 1);
|
||||||
assertPosition(0, 0, this.editor.getCursorPosition());
|
assert.position(this.editor.getCursorPosition(), 0, 0);
|
||||||
assertFalse(called);
|
assert.false(called);
|
||||||
|
|
||||||
this.doc2.getSelection().moveCursorTo(1, 1);
|
this.doc2.getSelection().moveCursorTo(1, 1);
|
||||||
assertPosition(1, 1, this.editor.getCursorPosition());
|
assert.position(this.editor.getCursorPosition(), 1, 1);
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should use selection of new document" : function() {
|
"test: should use selection of new document" : function() {
|
||||||
|
|
@ -117,10 +119,10 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
this.doc2.getSelection().selectTo(1, 0);
|
this.doc2.getSelection().selectTo(1, 0);
|
||||||
|
|
||||||
this.editor.setDocument(this.doc1);
|
this.editor.setDocument(this.doc1);
|
||||||
assertPosition(0, 1, this.editor.getSelection().getSelectionLead());
|
assert.position(this.editor.getSelection().getSelectionLead(), 0, 1);
|
||||||
|
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
assertPosition(1, 0, this.editor.getSelection().getSelectionLead());
|
assert.position(this.editor.getSelection().getSelectionLead(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: only changing the selection of the new doc should not have an effect" : function() {
|
"test: only changing the selection of the new doc should not have an effect" : function() {
|
||||||
|
|
@ -130,16 +132,16 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
|
|
||||||
this.editor.setDocument(this.doc1);
|
this.editor.setDocument(this.doc1);
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
assertPosition(0, 0, this.editor.getSelection().getSelectionLead());
|
assert.position(this.editor.getSelection().getSelectionLead(), 0, 0);
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
this.doc1.getSelection().selectTo(0, 1);
|
this.doc1.getSelection().selectTo(0, 1);
|
||||||
assertPosition(0, 0, this.editor.getSelection().getSelectionLead());
|
assert.position(this.editor.getSelection().getSelectionLead(), 0, 0);
|
||||||
assertFalse(called);
|
assert.false(called);
|
||||||
|
|
||||||
this.doc2.getSelection().selectTo(1, 1);
|
this.doc2.getSelection().selectTo(1, 1);
|
||||||
assertPosition(1, 1, this.editor.getSelection().getSelectionLead());
|
assert.position(this.editor.getSelection().getSelectionLead(), 1, 1);
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should use mode of new document" : function() {
|
"test: should use mode of new document" : function() {
|
||||||
|
|
@ -151,11 +153,14 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
this.doc1.setMode(new Text());
|
this.doc1.setMode(new Text());
|
||||||
assertFalse(called);
|
assert.false(called);
|
||||||
|
|
||||||
this.doc2.setMode(new JavaScriptMode());
|
this.doc2.setMode(new JavaScriptMode());
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -35,229 +35,240 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document",
|
|
||||||
"ace/UndoManager",
|
|
||||||
"ace/Editor",
|
|
||||||
"ace/test/MockRenderer"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
UndoManager,
|
|
||||||
Editor,
|
|
||||||
MockRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
var TextDocumentTest = new TestCase("TextDocumentTest", {
|
var Document = require("../document"),
|
||||||
|
UndoManager = require("../undomanager"),
|
||||||
|
//Editor = require("../editor"),
|
||||||
|
MockRenderer = require("./mockrenderer"),
|
||||||
|
Range = require("../range"),
|
||||||
|
assert = require("./assertions"),
|
||||||
|
async = require("async");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
|
|
||||||
"test: find matching opening bracket" : function() {
|
"test: find matching opening bracket" : function() {
|
||||||
var doc = new Document(["(()(", "())))"]);
|
var doc = new Document(["(()(", "())))"]);
|
||||||
|
|
||||||
assertPosition(0, 1, doc.findMatchingBracket({row: 0, column: 3}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 3}), 0, 1);
|
||||||
assertPosition(1, 0, doc.findMatchingBracket({row: 1, column: 2}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 2}), 1, 0);
|
||||||
assertPosition(0, 3, doc.findMatchingBracket({row: 1, column: 3}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 3}), 0, 3);
|
||||||
assertPosition(0, 0, doc.findMatchingBracket({row: 1, column: 4}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 4}), 0, 0);
|
||||||
assertEquals(null, doc.findMatchingBracket({row: 1, column: 5}));
|
assert.equal(doc.findMatchingBracket({row: 1, column: 5}), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find matching closing bracket" : function() {
|
"test: find matching closing bracket" : function() {
|
||||||
var doc = new Document(["(()(", "())))"]);
|
var doc = new Document(["(()(", "())))"]);
|
||||||
|
|
||||||
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||||
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 1, 1);
|
||||||
assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 4}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 4}), 1, 2);
|
||||||
assertPosition(0, 2, doc.findMatchingBracket({row: 0, column: 2}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 2}), 0, 2);
|
||||||
assertPosition(1, 3, doc.findMatchingBracket({row: 0, column: 1}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 1}), 1, 3);
|
||||||
assertEquals(null, doc.findMatchingBracket({row: 0, column: 0}));
|
assert.equal(doc.findMatchingBracket({row: 0, column: 0}), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: match different bracket types" : function() {
|
"test: match different bracket types" : function() {
|
||||||
var doc = new Document(["({[", ")]}"]);
|
var doc = new Document(["({[", ")]}"]);
|
||||||
|
|
||||||
assertPosition(1, 0, doc.findMatchingBracket({row: 0, column: 1}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 1}), 1, 0);
|
||||||
assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 2}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 2}), 1, 2);
|
||||||
assertPosition(1, 1, doc.findMatchingBracket({row: 0, column: 3}));
|
assert.position(doc.findMatchingBracket({row: 0, column: 3}), 1, 1);
|
||||||
|
|
||||||
assertPosition(0, 0, doc.findMatchingBracket({row: 1, column: 1}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 1}), 0, 0);
|
||||||
assertPosition(0, 2, doc.findMatchingBracket({row: 1, column: 2}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 2}), 0, 2);
|
||||||
assertPosition(0, 1, doc.findMatchingBracket({row: 1, column: 3}));
|
assert.position(doc.findMatchingBracket({row: 1, column: 3}), 0, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines down" : function() {
|
"test: move lines down" : function() {
|
||||||
var doc = new Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
|
console.log(doc.toString().replace(/\n/g, "\\n"));
|
||||||
doc.moveLinesDown(0, 1);
|
doc.moveLinesDown(0, 1);
|
||||||
assertEquals(["3", "1", "2", "4"].join("\n"), doc.toString());
|
console.log(doc.toString().replace(/\n/g, "\\n"));
|
||||||
|
assert.equal(doc.toString(), ["3", "1", "2", "4"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesDown(1, 2);
|
doc.moveLinesDown(1, 2);
|
||||||
assertEquals(["3", "4", "1", "2"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "4", "1", "2"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesDown(2, 3);
|
doc.moveLinesDown(2, 3);
|
||||||
assertEquals(["3", "4", "1", "2"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "4", "1", "2"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesDown(2, 2);
|
doc.moveLinesDown(2, 2);
|
||||||
assertEquals(["3", "4", "2", "1"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "4", "2", "1"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines up" : function() {
|
"__test: move lines up" : function() {
|
||||||
var doc = new Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
|
console.log(doc.toString().replace(/\n/g, "\\n"));
|
||||||
doc.moveLinesUp(2, 3);
|
doc.moveLinesUp(2, 3);
|
||||||
assertEquals(["1", "3", "4", "2"].join("\n"), doc.toString());
|
console.log(doc.toString().replace(/\n/g, "\\n"));
|
||||||
|
assert.equal(doc.toString(), ["1", "3", "4", "2"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesUp(1, 2);
|
doc.moveLinesUp(1, 2);
|
||||||
assertEquals(["3", "4", "1", "2"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "4", "1", "2"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesUp(0, 1);
|
doc.moveLinesUp(0, 1);
|
||||||
assertEquals(["3", "4", "1", "2"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "4", "1", "2"].join("\n"));
|
||||||
|
|
||||||
doc.moveLinesUp(2, 2);
|
doc.moveLinesUp(2, 2);
|
||||||
assertEquals(["3", "1", "4", "2"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["3", "1", "4", "2"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate lines" : function() {
|
"test: duplicate lines" : function() {
|
||||||
var doc = new Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
doc.duplicateLines(1, 2);
|
doc.duplicateLines(1, 2);
|
||||||
assertEquals(["1", "2", "3", "2", "3", "4"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3", "2", "3", "4"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate last line" : function() {
|
"test: duplicate last line" : function() {
|
||||||
var doc = new Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
|
|
||||||
doc.duplicateLines(2, 2);
|
doc.duplicateLines(2, 2);
|
||||||
assertEquals(["1", "2", "3", "3"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3", "3"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate first line" : function() {
|
"test: duplicate first line" : function() {
|
||||||
var doc = new Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
|
|
||||||
doc.duplicateLines(0, 0);
|
doc.duplicateLines(0, 0);
|
||||||
assertEquals(["1", "1", "2", "3"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "1", "2", "3"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should handle unix style new lines" : function() {
|
"test: should handle unix style new lines" : function() {
|
||||||
var doc = new Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
|
||||||
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should handle windows style new lines" : function() {
|
"test: should handle windows style new lines" : function() {
|
||||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
|
|
||||||
doc.setNewLineMode("unix");
|
doc.setNewLineMode("unix");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
|
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
|
||||||
var doc = new Document(["1", "2", "3"].join("\n"));
|
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||||
doc.setNewLineMode("windows");
|
doc.setNewLineMode("windows");
|
||||||
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\r\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
|
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
|
||||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
|
|
||||||
doc.setNewLineMode("unix");
|
doc.setNewLineMode("unix");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'auto' should use detect the incoming nl type": function() {
|
"test: set new line mode to 'auto' should detect the incoming nl type": function() {
|
||||||
var doc = new Document(["1", "2", "3"].join("\n"));
|
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||||
|
|
||||||
doc.setNewLineMode("auto");
|
doc.setNewLineMode("auto");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\n"));
|
||||||
|
|
||||||
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
|
|
||||||
doc.setNewLineMode("auto");
|
doc.setNewLineMode("auto");
|
||||||
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
assert.equal(doc.toString(), ["1", "2", "3"].join("\r\n"));
|
||||||
|
|
||||||
doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
||||||
assertEquals(["4", "5", "6"].join("\n"), doc.toString());
|
assert.equal(["4", "5", "6"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: undo/redo for delete line" : function() {
|
"__test: undo/redo for delete line" : function() {
|
||||||
var doc = new Document(["111", "222", "333"]);
|
var doc = new Document(["111", "222", "333"]);
|
||||||
var undoManager = new UndoManager();
|
var undoManager = new UndoManager();
|
||||||
doc.setUndoManager(undoManager);
|
doc.setUndoManager(undoManager);
|
||||||
|
|
||||||
var initialText = doc.toString();
|
var initialText = doc.toString();
|
||||||
|
|
||||||
|
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
var step1 = doc.toString();
|
var step1 = doc.toString();
|
||||||
assertEquals("222\n333", step1);
|
assert.equal(step1, "222\n333");
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
var step2 = doc.toString();
|
var step2 = doc.toString();
|
||||||
assertEquals("333", step2);
|
assert.equal(step2, "333");
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
var step3 = doc.toString();
|
var step3 = doc.toString();
|
||||||
assertEquals("", step3);
|
assert.equal(step3, "");
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
|
|
||||||
|
|
||||||
undoManager.undo();
|
undoManager.undo();
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
assertEquals(step2, doc.toString());
|
assert.equal(doc.toString(), step2);
|
||||||
|
|
||||||
undoManager.undo();
|
undoManager.undo();
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
assertEquals(step1, doc.toString());
|
assert.equal(doc.toString(), step1);
|
||||||
|
|
||||||
undoManager.undo();
|
undoManager.undo();
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
assertEquals(initialText, doc.toString());
|
assert.equal(doc.toString(), initialText);
|
||||||
|
|
||||||
undoManager.undo();
|
undoManager.undo();
|
||||||
doc.$informUndoManager.call();
|
doc.$informUndoManager.call();
|
||||||
assertEquals(initialText, doc.toString());
|
assert.equal(doc.toString(), initialText);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert document to screen coordinates" : function() {
|
"test: convert document to screen coordinates" : function() {
|
||||||
var doc = new Document("01234\t567890\t1234");
|
var doc = new Document("01234\t567890\t1234");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, doc.documentToScreenColumn(0, 4));
|
assert.equal(doc.documentToScreenColumn(0, 4), 4);
|
||||||
assertEquals(5, doc.documentToScreenColumn(0, 5));
|
assert.equal(doc.documentToScreenColumn(0, 5), 5);
|
||||||
assertEquals(9, doc.documentToScreenColumn(0, 6));
|
assert.equal(doc.documentToScreenColumn(0, 6), 9);
|
||||||
assertEquals(15, doc.documentToScreenColumn(0, 12));
|
assert.equal(doc.documentToScreenColumn(0, 12), 15);
|
||||||
assertEquals(19, doc.documentToScreenColumn(0, 13));
|
assert.equal(doc.documentToScreenColumn(0, 13), 19);
|
||||||
|
|
||||||
doc.setTabSize(2);
|
doc.setTabSize(2);
|
||||||
|
|
||||||
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, doc.documentToScreenColumn(0, 4));
|
assert.equal(doc.documentToScreenColumn(0, 4), 4);
|
||||||
assertEquals(5, doc.documentToScreenColumn(0, 5));
|
assert.equal(doc.documentToScreenColumn(0, 5), 5);
|
||||||
assertEquals(7, doc.documentToScreenColumn(0, 6));
|
assert.equal(doc.documentToScreenColumn(0, 6), 7);
|
||||||
assertEquals(13, doc.documentToScreenColumn(0, 12));
|
assert.equal(doc.documentToScreenColumn(0, 12), 13);
|
||||||
assertEquals(15, doc.documentToScreenColumn(0, 13));
|
assert.equal(doc.documentToScreenColumn(0, 13), 15);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert document to scrren coordinates with leading tabs": function() {
|
"test: convert document to scrren coordinates with leading tabs": function() {
|
||||||
var doc = new Document("\t\t123");
|
var doc = new Document("\t\t123");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
assert.equal(doc.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, doc.documentToScreenColumn(0, 1));
|
assert.equal(doc.documentToScreenColumn(0, 1), 4);
|
||||||
assertEquals(8, doc.documentToScreenColumn(0, 2));
|
assert.equal(doc.documentToScreenColumn(0, 2), 8);
|
||||||
assertEquals(9, doc.documentToScreenColumn(0, 3));
|
assert.equal(doc.documentToScreenColumn(0, 3), 9);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert screen to document coordinates" : function() {
|
"test: convert screen to document coordinates" : function() {
|
||||||
var doc = new Document("01234\t567890\t1234");
|
var doc = new Document("01234\t567890\t1234");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.screenToDocumentColumn(0, 0));
|
assert.equal(doc.screenToDocumentColumn(0, 0), 0);
|
||||||
assertEquals(4, doc.screenToDocumentColumn(0, 4));
|
assert.equal(doc.screenToDocumentColumn(0, 4), 4);
|
||||||
assertEquals(5, doc.screenToDocumentColumn(0, 5));
|
assert.equal(doc.screenToDocumentColumn(0, 5), 5);
|
||||||
assertEquals(5, doc.screenToDocumentColumn(0, 6));
|
assert.equal(doc.screenToDocumentColumn(0, 6), 5);
|
||||||
assertEquals(5, doc.screenToDocumentColumn(0, 7));
|
assert.equal(doc.screenToDocumentColumn(0, 7), 5);
|
||||||
assertEquals(5, doc.screenToDocumentColumn(0, 8));
|
assert.equal(doc.screenToDocumentColumn(0, 8), 5);
|
||||||
assertEquals(6, doc.screenToDocumentColumn(0, 9));
|
assert.equal(doc.screenToDocumentColumn(0, 9), 6);
|
||||||
assertEquals(12, doc.screenToDocumentColumn(0, 15));
|
assert.equal(doc.screenToDocumentColumn(0, 15), 12);
|
||||||
assertEquals(13, doc.screenToDocumentColumn(0, 19));
|
assert.equal(doc.screenToDocumentColumn(0, 19), 13);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test)
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -37,26 +37,31 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
||||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
var oop = require("pilot/oop").oop;
|
var oop = require("pilot/oop").oop;
|
||||||
|
var assert = require("./assertions");
|
||||||
|
|
||||||
var EventEmitter = function() {};
|
var EventEmitter = function() {};
|
||||||
|
|
||||||
oop.implement(EventEmitter.prototype, EventEmitter);
|
oop.implement(EventEmitter.prototype, EventEmitter);
|
||||||
|
|
||||||
var EventEmitterTest = new TestCase("EventEmitterTest", {
|
var Test = {
|
||||||
"test: dispatch event with no data" : function() {
|
"test: dispatch event with no data" : function() {
|
||||||
var emitter = new EventEmitter();
|
var emitter = new EventEmitter();
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
emitter.addEventListener("juhu", function(e) {
|
emitter.addEventListener("juhu", function(e) {
|
||||||
called = true;
|
called = true;
|
||||||
assertEquals("juhu", e.type);
|
assert.equal(e.type, "juhu");
|
||||||
});
|
});
|
||||||
|
|
||||||
emitter._dispatchEvent("juhu");
|
emitter._dispatchEvent("juhu");
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test)
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([], function() {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
MockRenderer = function(visibleRowCount) {
|
MockRenderer = function(visibleRowCount) {
|
||||||
this.container = document.createElement("div");
|
this.container = document.createElement("div");
|
||||||
|
|
@ -113,5 +113,14 @@ MockRenderer.prototype.addMarker = function() {
|
||||||
MockRenderer.prototype.setBreakpoints = function() {
|
MockRenderer.prototype.setBreakpoints = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MockRenderer.prototype.updateFull = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
MockRenderer.prototype.showCursor = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
MockRenderer.prototype.visualizeFocus = function() {
|
||||||
|
};
|
||||||
|
|
||||||
return MockRenderer;
|
return MockRenderer;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,24 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document",
|
|
||||||
"ace/Editor",
|
|
||||||
"ace/test/MockRenderer"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
Editor,
|
|
||||||
MockRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
var NavigationTest = TestCase("NavigationTest",
|
var dom = require('jsdom/level2/html').dom.level2.html;
|
||||||
{
|
var browser = require('jsdom/browser/index').windowAugmentation(dom);
|
||||||
|
|
||||||
|
global.document = browser.document;
|
||||||
|
global.window = browser.window;
|
||||||
|
global.self = browser.self;
|
||||||
|
global.navigator = browser.navigator;
|
||||||
|
global.location = browser.location;
|
||||||
|
|
||||||
|
var Document = require("../Document"),
|
||||||
|
Editor = require("../Editor"),
|
||||||
|
MockRenderer = require("./mockrenderer"),
|
||||||
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
|
||||||
|
var Test = {
|
||||||
createTextDocument : function(rows, cols) {
|
createTextDocument : function(rows, cols) {
|
||||||
var line = new Array(cols + 1).join("a");
|
var line = new Array(cols + 1).join("a");
|
||||||
var text = new Array(rows).join(line + "\n") + line;
|
var text = new Array(rows).join(line + "\n") + line;
|
||||||
|
|
@ -60,8 +66,8 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
editor.navigateFileEnd();
|
editor.navigateFileEnd();
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
|
|
||||||
assertTrue(editor.getFirstVisibleRow() <= cursor.row);
|
assert.true(editor.getFirstVisibleRow() <= cursor.row);
|
||||||
assertTrue(editor.getLastVisibleRow() >= cursor.row);
|
assert.true(editor.getLastVisibleRow() >= cursor.row);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: navigate to start of file should scroll the first row into view" : function() {
|
"test: navigate to start of file should scroll the first row into view" : function() {
|
||||||
|
|
@ -71,7 +77,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
||||||
editor.navigateFileStart();
|
editor.navigateFileStart();
|
||||||
|
|
||||||
assertEquals(0, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: goto hidden line should scroll the line into the middle of the viewport" : function() {
|
"test: goto hidden line should scroll the line into the middle of the viewport" : function() {
|
||||||
|
|
@ -79,33 +85,33 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(101);
|
editor.gotoLine(101);
|
||||||
assertPosition(100, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 100, 0);
|
||||||
assertEquals(90, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 90);
|
||||||
|
|
||||||
editor.navigateTo(100, 0);
|
editor.navigateTo(100, 0);
|
||||||
editor.gotoLine(11);
|
editor.gotoLine(11);
|
||||||
assertPosition(10, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 10, 0);
|
||||||
assertEquals(0, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||||
|
|
||||||
editor.navigateTo(100, 0);
|
editor.navigateTo(100, 0);
|
||||||
editor.gotoLine(6);
|
editor.gotoLine(6);
|
||||||
assertPosition(5, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 5, 0);
|
||||||
assertEquals(0, editor.getFirstVisibleRow());
|
assert.equal(0, editor.getFirstVisibleRow(), 0);
|
||||||
|
|
||||||
editor.navigateTo(100, 0);
|
editor.navigateTo(100, 0);
|
||||||
editor.gotoLine(1);
|
editor.gotoLine(1);
|
||||||
assertPosition(0, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 0);
|
||||||
assertEquals(0, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(191);
|
editor.gotoLine(191);
|
||||||
assertPosition(190, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 190, 0);
|
||||||
assertEquals(180, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 180);
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(196);
|
editor.gotoLine(196);
|
||||||
assertPosition(195, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 195, 0);
|
||||||
assertEquals(180, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 180);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: goto visible line should only move the cursor and not scroll": function() {
|
"test: goto visible line should only move the cursor and not scroll": function() {
|
||||||
|
|
@ -113,43 +119,46 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(12);
|
editor.gotoLine(12);
|
||||||
assertPosition(11, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 11, 0);
|
||||||
assertEquals(0, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 0);
|
||||||
|
|
||||||
editor.navigateTo(30, 0);
|
editor.navigateTo(30, 0);
|
||||||
editor.gotoLine(33);
|
editor.gotoLine(33);
|
||||||
assertPosition(32, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 32, 0);
|
||||||
assertEquals(30, editor.getFirstVisibleRow());
|
assert.equal(editor.getFirstVisibleRow(), 30);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() {
|
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() {
|
||||||
var editor = new Editor(new MockRenderer(), new Document(["123456", "1"]));
|
var editor = new Editor(new MockRenderer(), new Document(["123456", "1"]));
|
||||||
|
|
||||||
editor.navigateTo(0, 6);
|
editor.navigateTo(0, 6);
|
||||||
assertPosition(0, 6, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 6);
|
||||||
|
|
||||||
editor.navigateDown();
|
editor.navigateDown();
|
||||||
assertPosition(1, 1, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 1);
|
||||||
|
|
||||||
editor.navigateUp();
|
editor.navigateUp();
|
||||||
assertPosition(0, 6, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 6);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: reset desired column on navigate left or right": function() {
|
"test: reset desired column on navigate left or right": function() {
|
||||||
var editor = new Editor(new MockRenderer(), new Document(["123456", "12"]));
|
var editor = new Editor(new MockRenderer(), new Document(["123456", "12"]));
|
||||||
|
|
||||||
editor.navigateTo(0, 6);
|
editor.navigateTo(0, 6);
|
||||||
assertPosition(0, 6, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 6);
|
||||||
|
|
||||||
editor.navigateDown();
|
editor.navigateDown();
|
||||||
assertPosition(1, 2, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 2);
|
||||||
|
|
||||||
editor.navigateLeft();
|
editor.navigateLeft();
|
||||||
assertPosition(1, 1, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 1);
|
||||||
|
|
||||||
editor.navigateUp();
|
editor.navigateUp();
|
||||||
assertPosition(0, 1, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 1);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test)
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -35,118 +35,119 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Range"
|
|
||||||
], function(
|
|
||||||
Range
|
|
||||||
) {
|
|
||||||
|
|
||||||
RangeTest = new TestCase("RangeTest", {
|
var Range = require("../range"),
|
||||||
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
"test: create range": function() {
|
"test: create range": function() {
|
||||||
var range = new Range(1,2,3,4);
|
var range = new Range(1,2,3,4);
|
||||||
|
|
||||||
assertEquals(1, range.start.row);
|
assert.equal(range.start.row, 1);
|
||||||
assertEquals(2, range.start.column);
|
assert.equal(range.start.column, 2);
|
||||||
assertEquals(3, range.end.row);
|
assert.equal(range.end.row, 3);
|
||||||
assertEquals(4, range.end.column);
|
assert.equal(range.end.column, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: create from points": function() {
|
"test: create from points": function() {
|
||||||
var range = Range.fromPoints({row: 1, column: 2}, {row:3, column:4});
|
var range = Range.fromPoints({row: 1, column: 2}, {row:3, column:4});
|
||||||
|
|
||||||
assertEquals(1, range.start.row);
|
assert.equal(range.start.row, 1);
|
||||||
assertEquals(2, range.start.column);
|
assert.equal(range.start.column, 2);
|
||||||
assertEquals(3, range.end.row);
|
assert.equal(range.end.row, 3);
|
||||||
assertEquals(4, range.end.column);
|
assert.equal(range.end.column, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: clip to rows": function() {
|
"test: clip to rows": function() {
|
||||||
assertRange(10, 0, 31, 0, new Range(0, 20, 100, 30).clipRows(10, 30));
|
assert.range(new Range(0, 20, 100, 30).clipRows(10, 30), 10, 0, 31, 0);
|
||||||
assertRange(10, 0, 30, 10, new Range(0, 20, 30, 10).clipRows(10, 30));
|
assert.range(new Range(0, 20, 30, 10).clipRows(10, 30), 10, 0, 30, 10);
|
||||||
|
|
||||||
var range = new Range(0, 20, 3, 10);
|
var range = new Range(0, 20, 3, 10);
|
||||||
var range = range.clipRows(10, 30);
|
var range = range.clipRows(10, 30);
|
||||||
|
|
||||||
assertTrue(range.isEmpty());
|
assert.true(range.isEmpty());
|
||||||
assertRange(10, 0, 10, 0, range);
|
assert.range(range, 10, 0, 10, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: isEmpty": function() {
|
"test: isEmpty": function() {
|
||||||
var range = new Range(1, 2, 1, 2);
|
var range = new Range(1, 2, 1, 2);
|
||||||
assertTrue(range.isEmpty());
|
assert.true(range.isEmpty());
|
||||||
|
|
||||||
var range = new Range(1, 2, 1, 6);
|
var range = new Range(1, 2, 1, 6);
|
||||||
assertFalse(range.isEmpty());
|
assert.false(range.isEmpty());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: is multi line": function() {
|
"test: is multi line": function() {
|
||||||
var range = new Range(1, 2, 1, 6);
|
var range = new Range(1, 2, 1, 6);
|
||||||
assertFalse(range.isMultiLine());
|
assert.false(range.isMultiLine());
|
||||||
|
|
||||||
var range = new Range(1, 2, 2, 6);
|
var range = new Range(1, 2, 2, 6);
|
||||||
assertTrue(range.isMultiLine());
|
assert.true(range.isMultiLine());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: clone": function() {
|
"test: clone": function() {
|
||||||
var range = new Range(1, 2, 3, 4);
|
var range = new Range(1, 2, 3, 4);
|
||||||
var clone = range.clone();
|
var clone = range.clone();
|
||||||
|
|
||||||
assertPosition(1, 2, clone.start);
|
assert.position(clone.start, 1, 2);
|
||||||
assertPosition(3, 4, clone.end);
|
assert.position(clone.end, 3, 4);
|
||||||
|
|
||||||
clone.start.column = 20;
|
clone.start.column = 20;
|
||||||
assertPosition(1, 2, range.start);
|
assert.position(range.start, 1, 2);
|
||||||
|
|
||||||
clone.end.column = 20;
|
clone.end.column = 20;
|
||||||
assertPosition(3, 4, range.end);
|
assert.position(range.end, 3, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: contains for multi line ranges": function() {
|
"test: contains for multi line ranges": function() {
|
||||||
var range = new Range(1, 10, 5, 20);
|
var range = new Range(1, 10, 5, 20);
|
||||||
|
|
||||||
assertTrue(range.contains(1, 10));
|
assert.true(range.contains(1, 10));
|
||||||
assertTrue(range.contains(2, 0));
|
assert.true(range.contains(2, 0));
|
||||||
assertTrue(range.contains(3, 100));
|
assert.true(range.contains(3, 100));
|
||||||
assertTrue(range.contains(5, 19));
|
assert.true(range.contains(5, 19));
|
||||||
assertTrue(range.contains(5, 20));
|
assert.true(range.contains(5, 20));
|
||||||
|
|
||||||
assertFalse(range.contains(1, 9));
|
assert.false(range.contains(1, 9));
|
||||||
assertFalse(range.contains(0, 0));
|
assert.false(range.contains(0, 0));
|
||||||
assertFalse(range.contains(5, 21));
|
assert.false(range.contains(5, 21));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: contains for single line ranges": function() {
|
"test: contains for single line ranges": function() {
|
||||||
var range = new Range(1, 10, 1, 20);
|
var range = new Range(1, 10, 1, 20);
|
||||||
|
|
||||||
assertTrue(range.contains(1, 10));
|
assert.true(range.contains(1, 10));
|
||||||
assertTrue(range.contains(1, 15));
|
assert.true(range.contains(1, 15));
|
||||||
assertTrue(range.contains(1, 20));
|
assert.true(range.contains(1, 20));
|
||||||
|
|
||||||
assertFalse(range.contains(0, 9));
|
assert.false(range.contains(0, 9));
|
||||||
assertFalse(range.contains(2, 9));
|
assert.false(range.contains(2, 9));
|
||||||
assertFalse(range.contains(1, 9));
|
assert.false(range.contains(1, 9));
|
||||||
assertFalse(range.contains(1, 21));
|
assert.false(range.contains(1, 21));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: extend range": function() {
|
"test: extend range": function() {
|
||||||
var range = new Range(2, 10, 2, 30);
|
var range = new Range(2, 10, 2, 30);
|
||||||
|
|
||||||
var range = range.extend(2, 5);
|
var range = range.extend(2, 5);
|
||||||
assertRange(2, 5, 2, 30, range);
|
assert.range(range, 2, 5, 2, 30);
|
||||||
|
|
||||||
var range = range.extend(2, 35);
|
var range = range.extend(2, 35);
|
||||||
assertRange(2, 5, 2, 35, range);
|
assert.range(range, 2, 5, 2, 35);
|
||||||
|
|
||||||
var range = range.extend(2, 15);
|
var range = range.extend(2, 15);
|
||||||
assertRange(2, 5, 2, 35, range);
|
assert.range(range, 2, 5, 2, 35);
|
||||||
|
|
||||||
var range = range.extend(1, 4);
|
var range = range.extend(1, 4);
|
||||||
assertRange(1, 4, 2, 35, range);
|
assert.range(range, 1, 4, 2, 35);
|
||||||
|
|
||||||
var range = range.extend(6, 10);
|
var range = range.extend(6, 10);
|
||||||
assertRange(1, 4, 6, 10, range);
|
assert.range(range, 1, 4, 6, 10);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -35,16 +35,13 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document",
|
|
||||||
"ace/Search"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
Search
|
|
||||||
) {
|
|
||||||
|
|
||||||
var SearchTest = new TestCase("SearchTest", {
|
var Document = require("../document"),
|
||||||
|
Search = require("../search"),
|
||||||
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
"test: configure the search object" : function() {
|
"test: configure the search object" : function() {
|
||||||
var search = new Search();
|
var search = new Search();
|
||||||
search.set({
|
search.set({
|
||||||
|
|
@ -60,8 +57,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(0, 5, range.start);
|
assert.position(range.start, 0, 5);
|
||||||
assertPosition(0, 12, range.end);
|
assert.position(range.end, 0, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find simple text in next line" : function() {
|
"test: find simple text in next line" : function() {
|
||||||
|
|
@ -71,8 +68,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 5, range.start);
|
assert.position(range.start, 1, 5);
|
||||||
assertPosition(1, 12, range.end);
|
assert.position(range.end, 1, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find text starting at cursor position" : function() {
|
"test: find text starting at cursor position" : function() {
|
||||||
|
|
@ -83,8 +80,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 5, range.start);
|
assert.position(range.start, 1, 5);
|
||||||
assertPosition(1, 12, range.end);
|
assert.position(range.end, 1, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search is off by default" : function() {
|
"test: wrap search is off by default" : function() {
|
||||||
|
|
@ -95,7 +92,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
needle: "kinners"
|
needle: "kinners"
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(null, search.find(doc));
|
assert.equal(search.find(doc), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search should wrap at file end" : function() {
|
"test: wrap search should wrap at file end" : function() {
|
||||||
|
|
@ -108,8 +105,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 5, range.start);
|
assert.position(range.start, 1, 5);
|
||||||
assertPosition(1, 12, range.end);
|
assert.position(range.end, 1, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search with no match should return 'null'": function() {
|
"test: wrap search with no match should return 'null'": function() {
|
||||||
|
|
@ -121,7 +118,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
wrap: true
|
wrap: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(null, search.find(doc));
|
assert.equal(search.find(doc), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: case sensitive is by default off": function() {
|
"test: case sensitive is by default off": function() {
|
||||||
|
|
@ -131,7 +128,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
needle: "JUHU"
|
needle: "JUHU"
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(null, search.find(doc));
|
assert.range(search.find(doc), 1, 0, 1, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: case sensitive search": function() {
|
"test: case sensitive search": function() {
|
||||||
|
|
@ -143,8 +140,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 5, range.start);
|
assert.equal(range, null);
|
||||||
assertPosition(1, 12, range.end);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: whole word search should not match inside of words": function() {
|
"test: whole word search should not match inside of words": function() {
|
||||||
|
|
@ -156,8 +152,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 5, range.start);
|
assert.position(range.start, 1, 5);
|
||||||
assertPosition(1, 12, range.end);
|
assert.position(range.end, 1, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find backwards": function() {
|
"test: find backwards": function() {
|
||||||
|
|
@ -169,8 +165,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(0, 5, range.start);
|
assert.position(range.start, 0, 5);
|
||||||
assertPosition(0, 9, range.end);
|
assert.position(range.end, 0, 9);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find in selection": function() {
|
"test: find in selection": function() {
|
||||||
|
|
@ -185,15 +181,15 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 0, range.start);
|
assert.position(range.start, 1, 0);
|
||||||
assertPosition(1, 4, range.end);
|
assert.position(range.end, 1, 4);
|
||||||
|
|
||||||
doc.getSelection().setSelectionAnchor(0, 2);
|
doc.getSelection().setSelectionAnchor(0, 2);
|
||||||
doc.getSelection().selectTo(3, 2);
|
doc.getSelection().selectTo(3, 2);
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(1, 0, range.start);
|
assert.position(range.start, 1, 0);
|
||||||
assertPosition(1, 4, range.end);
|
assert.position(range.end, 1, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find backwards in selection": function() {
|
"test: find backwards in selection": function() {
|
||||||
|
|
@ -210,13 +206,13 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
doc.getSelection().selectTo(3, 2);
|
doc.getSelection().selectTo(3, 2);
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(2, 0, range.start);
|
assert.position(range.start, 2, 0);
|
||||||
assertPosition(2, 4, range.end);
|
assert.position(range.end, 2, 4);
|
||||||
|
|
||||||
doc.getSelection().setSelectionAnchor(0, 2);
|
doc.getSelection().setSelectionAnchor(0, 2);
|
||||||
doc.getSelection().selectTo(1, 2);
|
doc.getSelection().selectTo(1, 2);
|
||||||
|
|
||||||
assertEquals(null, search.find(doc));
|
assert.equal(search.find(doc), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: edge case - match directly before the cursor" : function() {
|
"test: edge case - match directly before the cursor" : function() {
|
||||||
|
|
@ -230,8 +226,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
doc.getSelection().moveCursorTo(2, 5);
|
doc.getSelection().moveCursorTo(2, 5);
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(2, 0, range.start);
|
assert.position(range.start, 2, 0);
|
||||||
assertPosition(2, 4, range.end);
|
assert.position(range.end, 2, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: edge case - match backwards directly after the cursor" : function() {
|
"test: edge case - match backwards directly after the cursor" : function() {
|
||||||
|
|
@ -246,8 +242,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
doc.getSelection().moveCursorTo(2, 0);
|
doc.getSelection().moveCursorTo(2, 0);
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(2, 0, range.start);
|
assert.position(range.start, 2, 0);
|
||||||
assertPosition(2, 4, range.end);
|
assert.position(range.end, 2, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find using a regular expression" : function() {
|
"test: find using a regular expression" : function() {
|
||||||
|
|
@ -259,8 +255,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(0, 3, range.start);
|
assert.position(range.start, 0, 3);
|
||||||
assertPosition(0, 6, range.end);
|
assert.position(range.end, 0, 6);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find using a regular expression and whole word" : function() {
|
"test: find using a regular expression and whole word" : function() {
|
||||||
|
|
@ -273,8 +269,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(0, 7, range.start);
|
assert.position(range.start, 0, 7);
|
||||||
assertPosition(0, 10, range.end);
|
assert.position(range.end, 0, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: use regular expressions with capture groups": function() {
|
"test: use regular expressions with capture groups": function() {
|
||||||
|
|
@ -286,8 +282,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
assertPosition(0, 6, range.start);
|
assert.position(range.start, 0, 6);
|
||||||
assertPosition(0, 8, range.end);
|
assert.position(range.end, 0, 8);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find all matches in selection" : function() {
|
"test: find all matches in selection" : function() {
|
||||||
|
|
@ -304,11 +300,11 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
|
|
||||||
var ranges = search.findAll(doc);
|
var ranges = search.findAll(doc);
|
||||||
|
|
||||||
assertEquals(2, ranges.length);
|
assert.equal(ranges.length, 2);
|
||||||
assertPosition(1, 1, ranges[0].start);
|
assert.position(ranges[0].start, 1, 1);
|
||||||
assertPosition(1, 3, ranges[0].end);
|
assert.position(ranges[0].end, 1, 3);
|
||||||
assertPosition(2, 1, ranges[1].start);
|
assert.position(ranges[1].start, 2, 1);
|
||||||
assertPosition(2, 3, ranges[1].end);
|
assert.position(ranges[1].end, 2, 3);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: replace() should return the replacement if the input matches the needle" : function() {
|
"test: replace() should return the replacement if the input matches the needle" : function() {
|
||||||
|
|
@ -316,9 +312,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
needle: "juhu"
|
needle: "juhu"
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals("kinners", search.replace("juhu", "kinners"));
|
assert.equal(search.replace("juhu", "kinners"), "kinners");
|
||||||
assertEquals(null, search.replace("", "kinners"));
|
assert.equal(search.replace("", "kinners"), null);
|
||||||
assertEquals(null, search.replace(" juhu", "kinners"));
|
assert.equal(search.replace(" juhu", "kinners"), null);
|
||||||
|
|
||||||
// regexp replacement
|
// regexp replacement
|
||||||
},
|
},
|
||||||
|
|
@ -329,11 +325,11 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals("kinners", search.replace("123", "kinners"));
|
assert.equal(search.replace("123", "kinners"), "kinners");
|
||||||
assertEquals("kinners", search.replace("01234", "kinners"));
|
assert.equal(search.replace("01234", "kinners"), "kinners");
|
||||||
assertEquals(null, search.replace("", "kinners"));
|
assert.equal(search.replace("", "kinners"), null);
|
||||||
assertEquals(null, search.replace("a12", "kinners"));
|
assert.equal(search.replace("a12", "kinners"), null);
|
||||||
assertEquals(null, search.replace("12a", "kinners"));
|
assert.equal(search.replace("12a", "kinners"), null);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: replace with RegExp match and capture groups" : function() {
|
"test: replace with RegExp match and capture groups" : function() {
|
||||||
|
|
@ -342,10 +338,13 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals("cd12", search.replace("ab12", "cd$1"));
|
assert.equal(search.replace("ab12", "cd$1"), "cd12");
|
||||||
assertEquals("-ab12-", search.replace("ab12", "-$&-"));
|
assert.equal(search.replace("ab12", "-$&-"), "-ab12-");
|
||||||
assertEquals("$", search.replace("ab12", "$$"));
|
assert.equal(search.replace("ab12", "$$"), "$");
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test)
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec();
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,12 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document"
|
|
||||||
], function(
|
|
||||||
Document
|
|
||||||
) {
|
|
||||||
|
|
||||||
var SelectionTest = TestCase("SelectionTest",
|
var Document = require("../document"),
|
||||||
{
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
createTextDocument : function(rows, cols) {
|
createTextDocument : function(rows, cols) {
|
||||||
var line = new Array(cols + 1).join("a");
|
var line = new Array(cols + 1).join("a");
|
||||||
var text = new Array(rows).join(line + "\n") + line;
|
var text = new Array(rows).join(line + "\n") + line;
|
||||||
|
|
@ -54,7 +52,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorFileEnd();
|
selection.moveCursorFileEnd();
|
||||||
assertPosition(199, 10, selection.getCursor());
|
assert.position(selection.getCursor(), 199, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: moveCursor to start of file should place the cursor on the first row and column" : function() {
|
"test: moveCursor to start of file should place the cursor on the first row and column" : function() {
|
||||||
|
|
@ -62,7 +60,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorFileStart();
|
selection.moveCursorFileStart();
|
||||||
assertPosition(0, 0, selection.getCursor());
|
assert.position(selection.getCursor(), 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move selection lead to end of file" : function() {
|
"test: move selection lead to end of file" : function() {
|
||||||
|
|
@ -74,8 +72,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
|
|
||||||
assertPosition(100, 5, range.start);
|
assert.position(range.start, 100, 5);
|
||||||
assertPosition(199, 10, range.end);
|
assert.position(range.end, 199, 10);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move selection lead to start of file" : function() {
|
"test: move selection lead to start of file" : function() {
|
||||||
|
|
@ -87,8 +85,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
|
|
||||||
assertPosition(0, 0, range.start);
|
assert.position(range.start, 0, 0);
|
||||||
assertPosition(100, 5, range.end);
|
assert.position(range.end, 100, 5);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move cursor word right" : function() {
|
"test: move cursor word right" : function() {
|
||||||
|
|
@ -97,38 +95,38 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorDown();
|
selection.moveCursorDown();
|
||||||
assertPosition(1, 0, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 0);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 1, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 1);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 5, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 5);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 6, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 6);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 13, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 13);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 15, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 15);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 18, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 18);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 20, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 20);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 22, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 22);
|
||||||
|
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(1, 23, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 23);
|
||||||
|
|
||||||
// wrap line
|
// wrap line
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
assertPosition(2, 0, selection.getCursor());
|
assert.position(selection.getCursor(), 2, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word right if cursor in word" : function() {
|
"test: select word right if cursor in word" : function() {
|
||||||
|
|
@ -138,7 +136,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.moveCursorTo(0, 2);
|
selection.moveCursorTo(0, 2);
|
||||||
selection.moveCursorWordRight();
|
selection.moveCursorWordRight();
|
||||||
|
|
||||||
assertPosition(0, 4, selection.getCursor());
|
assert.position(selection.getCursor(), 0, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: moveCursor word left" : function() {
|
"test: moveCursor word left" : function() {
|
||||||
|
|
@ -148,38 +146,38 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
|
|
||||||
selection.moveCursorDown();
|
selection.moveCursorDown();
|
||||||
selection.moveCursorLineEnd();
|
selection.moveCursorLineEnd();
|
||||||
assertPosition(1, 23, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 23);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 22, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 22);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 20, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 20);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 18, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 18);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 15, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 15);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 13, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 13);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 6, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 6);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 5, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 5);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 1, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 1);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(1, 0, selection.getCursor());
|
assert.position(selection.getCursor(), 1, 0);
|
||||||
|
|
||||||
// wrap line
|
// wrap line
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(0, 2, selection.getCursor());
|
assert.position(selection.getCursor(), 0, 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word left if cursor in word" : function() {
|
"test: select word left if cursor in word" : function() {
|
||||||
|
|
@ -189,7 +187,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.moveCursorTo(0, 8);
|
selection.moveCursorTo(0, 8);
|
||||||
|
|
||||||
selection.moveCursorWordLeft();
|
selection.moveCursorWordLeft();
|
||||||
assertPosition(0, 5, selection.getCursor());
|
assert.position(selection.getCursor(), 0, 5);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word right and select" : function() {
|
"test: select word right and select" : function() {
|
||||||
|
|
@ -201,8 +199,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
|
|
||||||
assertPosition(0, 0, range.start);
|
assert.position(range.start, 0, 0);
|
||||||
assertPosition(0, 4, range.end);
|
assert.position(range.end, 0, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word left and select" : function() {
|
"test: select word left and select" : function() {
|
||||||
|
|
@ -214,8 +212,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
|
|
||||||
assertPosition(0, 0, range.start);
|
assert.position(range.start, 0, 0);
|
||||||
assertPosition(0, 3, range.end);
|
assert.position(range.end, 0, 3);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor in word should select the word" : function() {
|
"test: select word with cursor in word should select the word" : function() {
|
||||||
|
|
@ -226,8 +224,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.selectWord();
|
selection.selectWord();
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
assertPosition(0, 5, range.start);
|
assert.position(range.start, 0, 5);
|
||||||
assertPosition(0, 12, range.end);
|
assert.position(range.end, 0, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor betwen white space and word should select the word" : function() {
|
"test: select word with cursor betwen white space and word should select the word" : function() {
|
||||||
|
|
@ -238,15 +236,15 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.selectWord();
|
selection.selectWord();
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
assertPosition(0, 0, range.start);
|
assert.position(range.start, 0, 0);
|
||||||
assertPosition(0, 4, range.end);
|
assert.position(range.end, 0, 4);
|
||||||
|
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
selection.selectWord();
|
selection.selectWord();
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
assertPosition(0, 5, range.start);
|
assert.position(range.start, 0, 5);
|
||||||
assertPosition(0, 12, range.end);
|
assert.position(range.end, 0, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor in white space should select white space" : function() {
|
"test: select word with cursor in white space should select white space" : function() {
|
||||||
|
|
@ -257,8 +255,8 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.selectWord();
|
selection.selectWord();
|
||||||
|
|
||||||
var range = selection.getRange();
|
var range = selection.getRange();
|
||||||
assertPosition(0, 4, range.start);
|
assert.position(range.start, 0, 4);
|
||||||
assertPosition(0, 6, range.end);
|
assert.position(range.end, 0, 6);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: moving cursor should fire a 'changeCursor' event" : function() {
|
"test: moving cursor should fire a 'changeCursor' event" : function() {
|
||||||
|
|
@ -273,7 +271,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
});
|
});
|
||||||
|
|
||||||
selection.moveCursorTo(0, 6);
|
selection.moveCursorTo(0, 6);
|
||||||
assertTrue(called);
|
assert.true(called);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: calling setCursor with the same position should not fire an event": function() {
|
"test: calling setCursor with the same position should not fire an event": function() {
|
||||||
|
|
@ -288,8 +286,11 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
});
|
});
|
||||||
|
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
assertFalse(called);
|
assert.false(called);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -35,21 +35,24 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
require.def([
|
require("../../../support/paths");
|
||||||
"ace/Document",
|
|
||||||
"ace/Editor",
|
|
||||||
"ace/mode/JavaScript",
|
|
||||||
"ace/test/MockRenderer"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
Editor,
|
|
||||||
jsMod,
|
|
||||||
MockRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
var JavaScriptMode = jsMod.JavaScript;
|
var dom = require('jsdom/level2/html').dom.level2.html;
|
||||||
var TextEditTest = TestCase("TextEditTest",
|
var browser = require('jsdom/browser/index').windowAugmentation(dom);
|
||||||
{
|
|
||||||
|
global.document = browser.document;
|
||||||
|
global.window = browser.window;
|
||||||
|
global.self = browser.self;
|
||||||
|
global.navigator = browser.navigator;
|
||||||
|
global.location = browser.location;
|
||||||
|
|
||||||
|
var Document = require("../document"),
|
||||||
|
Editor = require("../editor"),
|
||||||
|
JavaScriptMode = require("../mode/javascript").JavaScript,
|
||||||
|
MockRenderer = require("./mockrenderer"),
|
||||||
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
var Test = {
|
||||||
"test: delete line from the middle" : function() {
|
"test: delete line from the middle" : function() {
|
||||||
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
@ -57,23 +60,23 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("a\nc\nd", doc.toString());
|
assert.equal(doc.toString(), "a\nc\nd");
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("a\nd", doc.toString());
|
assert.equal(doc.toString(), "a\nd");
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("a\n", doc.toString());
|
assert.equal(doc.toString(), "a\n");
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("a\n", doc.toString());
|
assert.equal(doc.toString(), "a\n");
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete multiple selected lines" : function() {
|
"test: delete multiple selected lines" : function() {
|
||||||
|
|
@ -84,8 +87,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
assertEquals("a\nd", doc.toString());
|
assert.equal(doc.toString(), "a\nd");
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete first line" : function() {
|
"test: delete first line" : function() {
|
||||||
|
|
@ -94,8 +97,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("b\nc", doc.toString());
|
assert.equal(doc.toString(), "b\nc");
|
||||||
assertPosition(0, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete last" : function() {
|
"test: delete last" : function() {
|
||||||
|
|
@ -105,11 +108,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.moveCursorTo(2, 1);
|
editor.moveCursorTo(2, 1);
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
assertEquals("a\nb\n", doc.toString());
|
assert.equal(doc.toString(), "a\nb\n");
|
||||||
assertPosition(2, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: indent block" : function() {
|
"__test: indent block" : function() {
|
||||||
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
|
|
@ -118,18 +121,18 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
editor.blockIndent(" ");
|
editor.blockIndent(" ");
|
||||||
|
|
||||||
assertEquals(["a12345", " b12345", " c12345"].join("\n"),
|
assert.equal(["a12345", " b12345", " c12345"].join("\n"),
|
||||||
doc.toString());
|
doc.toString());
|
||||||
|
|
||||||
assertPosition(2, 7, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 7);
|
||||||
|
|
||||||
var range = editor.getSelectionRange();
|
var range = editor.getSelectionRange();
|
||||||
assertPosition(1, 7, range.start);
|
assert.position(range.start, 1, 7);
|
||||||
assertPosition(2, 7, range.end);
|
assert.position(range.end, 2, 7);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: outdent block" : function() {
|
"__test: outdent block" : function() {
|
||||||
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 3);
|
editor.moveCursorTo(0, 3);
|
||||||
|
|
@ -137,23 +140,21 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.blockOutdent(" ");
|
editor.blockOutdent(" ");
|
||||||
assertEquals([" a12345", "b12345", " c12345"].join("\n"),
|
assert.equal(doc.toString(), [" a12345", "b12345", " c12345"].join("\n"));
|
||||||
doc.toString());
|
|
||||||
|
|
||||||
assertPosition(2, 1, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
|
|
||||||
var range = editor.getSelectionRange();
|
var range = editor.getSelectionRange();
|
||||||
assertPosition(0, 1, range.start);
|
assert.position(range.start, 0, 1);
|
||||||
assertPosition(2, 1, range.end);
|
assert.position(range.end, 2, 1);
|
||||||
|
|
||||||
|
|
||||||
editor.blockOutdent(" ");
|
editor.blockOutdent(" ");
|
||||||
assertEquals([" a12345", "b12345", " c12345"].join("\n"),
|
assert.equal(doc.toString(), ["a12345", "b12345", "c12345"].join("\n"));
|
||||||
doc.toString());
|
|
||||||
|
|
||||||
var range = editor.getSelectionRange();
|
var range = editor.getSelectionRange();
|
||||||
assertPosition(0, 1, range.start);
|
assert.position(range.start, 0, 1);
|
||||||
assertPosition(2, 1, range.end);
|
assert.position(range.end, 2, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: outent without a selection should update cursor" : function() {
|
"test: outent without a selection should update cursor" : function() {
|
||||||
|
|
@ -163,8 +164,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.moveCursorTo(0, 3);
|
editor.moveCursorTo(0, 3);
|
||||||
editor.blockOutdent(" ");
|
editor.blockOutdent(" ");
|
||||||
|
|
||||||
assertEquals(" 12", doc.toString());
|
assert.equal(doc.toString(), " 12");
|
||||||
assertPosition(0, 1, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: comment lines should perserve selection" : function() {
|
"test: comment lines should perserve selection" : function() {
|
||||||
|
|
@ -176,11 +177,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
|
|
||||||
assertEquals(["// abc", "//cde"].join("\n"), doc.toString());
|
assert.equal(["// abc", "//cde"].join("\n"), doc.toString());
|
||||||
|
|
||||||
var selection = editor.getSelectionRange();
|
var selection = editor.getSelectionRange();
|
||||||
assertPosition(0, 4, selection.start);
|
assert.position(selection.start, 0, 4);
|
||||||
assertPosition(1, 4, selection.end);
|
assert.position(selection.end, 1, 4);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: uncomment lines should perserve selection" : function() {
|
"test: uncomment lines should perserve selection" : function() {
|
||||||
|
|
@ -194,8 +195,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
|
|
||||||
assertEquals([" abc", "cde"].join("\n"), doc.toString());
|
assert.equal([" abc", "cde"].join("\n"), doc.toString());
|
||||||
assertRange(0, 0, 1, 1, editor.getSelectionRange());
|
assert.range(editor.getSelectionRange(), 0, 0, 1, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: comment lines - if the selection end is at the line start it should stay there": function() {
|
"test: comment lines - if the selection end is at the line start it should stay there": function() {
|
||||||
|
|
@ -207,7 +208,7 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
assertRange(0, 2, 1, 0, editor.getSelectionRange());
|
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||||
|
|
||||||
// select up
|
// select up
|
||||||
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||||
|
|
@ -217,7 +218,7 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectUp();
|
editor.getSelection().selectUp();
|
||||||
|
|
||||||
editor.toggleCommentLines();
|
editor.toggleCommentLines();
|
||||||
assertRange(0, 2, 1, 0, editor.getSelectionRange());
|
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines down should select moved lines" : function() {
|
"test: move lines down should select moved lines" : function() {
|
||||||
|
|
@ -228,26 +229,26 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.moveLinesDown();
|
editor.moveLinesDown();
|
||||||
assertEquals(["33", "11", "22", "44"].join("\n"), doc.toString());
|
assert.equal(["33", "11", "22", "44"].join("\n"), doc.toString());
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||||
|
|
||||||
editor.moveLinesDown();
|
editor.moveLinesDown();
|
||||||
assertEquals(["33", "44", "11", "22"].join("\n"), doc.toString());
|
assert.equal(["33", "44", "11", "22"].join("\n"), doc.toString());
|
||||||
assertPosition(2, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
assertPosition(3, 2, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||||
assertPosition(2, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||||
|
|
||||||
// moving again should have no effect
|
// moving again should have no effect
|
||||||
editor.moveLinesDown();
|
editor.moveLinesDown();
|
||||||
assertEquals(["33", "44", "11", "22"].join("\n"), doc.toString());
|
assert.equal(["33", "44", "11", "22"].join("\n"), doc.toString());
|
||||||
assertPosition(2, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
assertPosition(3, 2, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 3, 2);
|
||||||
assertPosition(2, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines up should select moved lines" : function() {
|
"__test: move lines up should select moved lines" : function() {
|
||||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
|
|
@ -255,16 +256,16 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.moveLinesUp();
|
editor.moveLinesUp();
|
||||||
assertEquals(["11", "33", "44", "22"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["11", "33", "44", "22"].join("\n"));
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||||
|
|
||||||
editor.moveLinesUp();
|
editor.moveLinesUp();
|
||||||
assertEquals(["33", "44", "11", "22"].join("\n"), doc.toString());
|
assert.equal(doc.toString(), ["33", "44", "11", "22"].join("\n"));
|
||||||
assertPosition(0, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 0, 0);
|
||||||
assertPosition(2, 0, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 2, 0);
|
||||||
assertPosition(0, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move line without active selection should move cursor to start of the moved line" : function()
|
"test: move line without active selection should move cursor to start of the moved line" : function()
|
||||||
|
|
@ -276,14 +277,14 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
|
|
||||||
editor.moveLinesDown();
|
editor.moveLinesDown();
|
||||||
assertEquals(["11", "33", "22", "44"].join("\n"), doc.toString());
|
assert.equal(["11", "33", "22", "44"].join("\n"), doc.toString());
|
||||||
assertPosition(2, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
|
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
|
|
||||||
editor.moveLinesUp();
|
editor.moveLinesUp();
|
||||||
assertEquals(["11", "22", "33", "44"].join("\n"), doc.toString());
|
assert.equal(["11", "22", "33", "44"].join("\n"), doc.toString());
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: copy lines down should select lines and place cursor at the selection start" : function() {
|
"test: copy lines down should select lines and place cursor at the selection start" : function() {
|
||||||
|
|
@ -294,11 +295,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.copyLinesDown();
|
editor.copyLinesDown();
|
||||||
assertEquals(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
||||||
|
|
||||||
assertPosition(3, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 3, 0);
|
||||||
assertPosition(5, 0, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 5, 0);
|
||||||
assertPosition(3, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 3, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: copy lines up should select lines and place cursor at the selection start" : function() {
|
"test: copy lines up should select lines and place cursor at the selection start" : function() {
|
||||||
|
|
@ -309,11 +310,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
||||||
editor.copyLinesUp();
|
editor.copyLinesUp();
|
||||||
assertEquals(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), doc.toString());
|
||||||
|
|
||||||
assertPosition(1, 0, editor.getCursorPosition());
|
assert.position(editor.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, editor.getSelection().getSelectionAnchor());
|
assert.position(editor.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, editor.getSelection().getSelectionLead());
|
assert.position(editor.getSelection().getSelectionLead(), 1, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: input a tab with soft tab should convert it to spaces" : function() {
|
"test: input a tab with soft tab should convert it to spaces" : function() {
|
||||||
|
|
@ -324,11 +325,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
doc.setUseSoftTabs(true);
|
doc.setUseSoftTabs(true);
|
||||||
|
|
||||||
editor.onTextInput("\t");
|
editor.onTextInput("\t");
|
||||||
assertEquals(" ", doc.toString());
|
assert.equal(doc.toString(), " ");
|
||||||
|
|
||||||
doc.setTabSize(5);
|
doc.setTabSize(5);
|
||||||
editor.onTextInput("\t");
|
editor.onTextInput("\t");
|
||||||
assertEquals(" ", doc.toString());
|
assert.equal(doc.toString(), " ");
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: input tab without soft tabs should keep the tab character" : function() {
|
"test: input tab without soft tabs should keep the tab character" : function() {
|
||||||
|
|
@ -338,8 +339,11 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
doc.setUseSoftTabs(false);
|
doc.setUseSoftTabs(false);
|
||||||
|
|
||||||
editor.onTextInput("\t");
|
editor.onTextInput("\t");
|
||||||
assertEquals("\t", doc.toString());
|
assert.equal(doc.toString(), "\t");
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -34,17 +34,14 @@
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
var Document = "../document",
|
||||||
|
VirtualRenderer = "../virtual_renderer",
|
||||||
|
assert = "../assertions";
|
||||||
|
|
||||||
require.def([
|
var Test = {
|
||||||
"ace/Document",
|
|
||||||
"ace/VirtualRenderer"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
VirtualRenderer
|
|
||||||
) {
|
|
||||||
|
|
||||||
var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
|
||||||
|
|
||||||
"test: screen2text the column should be rounded to the next character edge" : function() {
|
"test: screen2text the column should be rounded to the next character edge" : function() {
|
||||||
var el = document.createElement("div");
|
var el = document.createElement("div");
|
||||||
el.style.left = "0px";
|
el.style.left = "0px";
|
||||||
|
|
@ -61,17 +58,20 @@ var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
||||||
renderer.characterWidth = 10;
|
renderer.characterWidth = 10;
|
||||||
renderer.lineHeight = 15;
|
renderer.lineHeight = 15;
|
||||||
|
|
||||||
assertPosition(0, 0, renderer.screenToTextCoordinates(0, 0));
|
assert.position(renderer.screenToTextCoordinates(0, 0), 0, 0);
|
||||||
assertPosition(0, 0, renderer.screenToTextCoordinates(4, 0));
|
assert.position(renderer.screenToTextCoordinates(4, 0), 0, 0);
|
||||||
assertPosition(0, 1, renderer.screenToTextCoordinates(5, 0));
|
assert.position(renderer.screenToTextCoordinates(5, 0), 0, 1);
|
||||||
assertPosition(0, 1, renderer.screenToTextCoordinates(9, 0));
|
assert.position(renderer.screenToTextCoordinates(9, 0), 0, 1);
|
||||||
assertPosition(0, 1, renderer.screenToTextCoordinates(10, 0));
|
assert.position(renderer.screenToTextCoordinates(10, 0), 0, 1);
|
||||||
assertPosition(0, 1, renderer.screenToTextCoordinates(14, 0));
|
assert.position(renderer.screenToTextCoordinates(14, 0), 0, 1);
|
||||||
assertPosition(0, 2, renderer.screenToTextCoordinates(15, 0));
|
assert.position(renderer.screenToTextCoordinates(15, 0), 0, 2);
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
// change tab size after setDocument (for text layer)
|
// change tab size after setDocument (for text layer)
|
||||||
});
|
};
|
||||||
|
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
|
||||||
|
if (module === require.main)
|
||||||
|
module.exports.exec()
|
||||||
|
|
|
||||||
|
|
@ -59,14 +59,14 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
this.setTheme(theme);
|
this.setTheme(theme);
|
||||||
|
|
||||||
this.scroller = document.createElement("div");
|
|
||||||
this.scroller.className = "ace_scroller";
|
|
||||||
this.container.appendChild(this.scroller);
|
|
||||||
|
|
||||||
this.$gutter = document.createElement("div");
|
this.$gutter = document.createElement("div");
|
||||||
this.$gutter.className = "ace_gutter";
|
this.$gutter.className = "ace_gutter";
|
||||||
this.container.appendChild(this.$gutter);
|
this.container.appendChild(this.$gutter);
|
||||||
|
|
||||||
|
this.scroller = document.createElement("div");
|
||||||
|
this.scroller.className = "ace_scroller";
|
||||||
|
this.container.appendChild(this.scroller);
|
||||||
|
|
||||||
this.content = document.createElement("div");
|
this.content = document.createElement("div");
|
||||||
this.content.style.position = "absolute";
|
this.content.style.position = "absolute";
|
||||||
this.scroller.appendChild(this.content);
|
this.scroller.appendChild(this.content);
|
||||||
|
|
@ -355,18 +355,13 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
// scrolling
|
// scrolling
|
||||||
if (changes & this.CHANGE_SCROLL) {
|
if (changes & this.CHANGE_SCROLL) {
|
||||||
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES) {
|
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
|
||||||
this.$textLayer.scrollLines(this.layerConfig);
|
|
||||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
|
||||||
this.$markerLayer.update(this.layerConfig);
|
|
||||||
this.$cursorLayer.update(this.layerConfig);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.$textLayer.update(this.layerConfig);
|
this.$textLayer.update(this.layerConfig);
|
||||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
else
|
||||||
this.$markerLayer.update(this.layerConfig);
|
this.$textLayer.scrollLines(this.layerConfig);
|
||||||
this.$cursorLayer.update(this.layerConfig);
|
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||||
}
|
this.$markerLayer.update(this.layerConfig);
|
||||||
|
this.$cursorLayer.update(this.layerConfig);
|
||||||
this.$updateScrollBar();
|
this.$updateScrollBar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -378,10 +373,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
else if (changes & this.CHANGE_LINES) {
|
else if (changes & this.CHANGE_LINES) {
|
||||||
this.$updateLines();
|
this.$updateLines();
|
||||||
this.$updateScrollBar();
|
this.$updateScrollBar();
|
||||||
}
|
|
||||||
else if (changes & this.CHANGE_SCROLL) {
|
|
||||||
this.$textLayer.scrollLines(this.layerConfig);
|
|
||||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
|
||||||
} if (changes & this.CHANGE_GUTTER) {
|
} if (changes & this.CHANGE_GUTTER) {
|
||||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||||
}
|
}
|
||||||
|
|
@ -616,7 +607,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.setTheme = function(theme) {
|
this.setTheme = function(theme) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
if (!theme || typeof theme == "string") {
|
if (!theme || typeof theme == "string") {
|
||||||
theme = theme || "ace/theme/TextMate";
|
theme = theme || "ace/theme/textmate";
|
||||||
require([theme], function(theme) {
|
require([theme], function(theme) {
|
||||||
afterLoad(theme);
|
afterLoad(theme);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
1
support/async
Submodule
1
support/async
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 6da8076355fc9f06191d39b8f5989159dc8a162c
|
||||||
1
support/jsdom
Submodule
1
support/jsdom
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 486755962dc0b69c60bfd04869ff1e0093406bae
|
||||||
1
support/node-htmlparser
Submodule
1
support/node-htmlparser
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 60d64db4a9a8b1a26bd099bc34f657bf096c4f39
|
||||||
Loading…
Add table
Add a link
Reference in a new issue