Rename insertText back to insert
This commit is contained in:
parent
91df7cd663
commit
6fe381f633
21 changed files with 67 additions and 83 deletions
|
|
@ -54,7 +54,7 @@ module.exports = {
|
|||
var doc = new Document("juhu\nkinners");
|
||||
var anchor = new Anchor(doc, 1, 4);
|
||||
|
||||
doc.insertText({row: 1, column: 1}, "123");
|
||||
doc.insert({row: 1, column: 1}, "123");
|
||||
assert.position(anchor.getPosition(), 1, 7);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ var Autocomplete = function() {
|
|||
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
|
||||
|
||||
"Esc": function(editor) { editor.completer.detach(); },
|
||||
"Space": function(editor) { editor.completer.detach(); editor.insertText(" ");},
|
||||
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
|
||||
"Return": function(editor) { editor.completer.insertMatch(); },
|
||||
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
|
||||
"Tab": function(editor) { editor.completer.insertMatch(); },
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ module.exports = {
|
|||
forceTokenize(doc)
|
||||
testStates(doc, ["comment_regex_allowed", "comment_regex_allowed"])
|
||||
|
||||
doc.insertText({row:0, column:2}, "\n*/")
|
||||
doc.insert({row:0, column:2}, "\n*/")
|
||||
testStates(doc, [undefined, undefined, "comment_regex_allowed"])
|
||||
|
||||
forceTokenize(doc)
|
||||
|
|
|
|||
|
|
@ -508,13 +508,13 @@ exports.commands = [{
|
|||
scrollIntoView: "selectionPart"
|
||||
}, {
|
||||
name: "insertstring",
|
||||
exec: function(editor, str) { editor.insertText(str); },
|
||||
exec: function(editor, str) { editor.insert(str); },
|
||||
multiSelectAction: "forEach",
|
||||
scrollIntoView: "cursor"
|
||||
}, {
|
||||
name: "inserttext",
|
||||
exec: function(editor, args) {
|
||||
editor.insertText(lang.stringRepeat(args.text || "", args.times || 1));
|
||||
editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
|
||||
},
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var Document = function(textOrLines) {
|
|||
} else if (Array.isArray(textOrLines)) {
|
||||
this.insertMergedLines({row: 0, column: 0}, textOrLines);
|
||||
} else {
|
||||
this.insertText({row: 0, column:0}, textOrLines);
|
||||
this.insert({row: 0, column:0}, textOrLines);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ var Document = function(textOrLines) {
|
|||
this.setValue = function(text) {
|
||||
var len = this.getLength();
|
||||
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
|
||||
this.insertText({row: 0, column:0}, text);
|
||||
this.insert({row: 0, column:0}, text);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -265,10 +265,6 @@ var Document = function(textOrLines) {
|
|||
};
|
||||
|
||||
// Deprecated methods retained for backwards compatibility.
|
||||
this.insert = function(position, text){
|
||||
console.warn('Use of document.insert is deprecated. Use the insertText method instead.');
|
||||
return this.insertText(position, text);
|
||||
};
|
||||
this.insertLines = function(row, lines) {
|
||||
console.warn('Use of document.insertLines is deprecated. Use the insertFullLines method instead.');
|
||||
return this.insertFullLines(row, lines);
|
||||
|
|
@ -282,8 +278,8 @@ var Document = function(textOrLines) {
|
|||
return this.insertMergedLines(position, ['', '']);
|
||||
};
|
||||
this.insertInLine = function(position, text) {
|
||||
console.warn('Use of document.insertInLine is deprecated. Use insertText instead.');
|
||||
return this.insertText(position, text);
|
||||
console.warn('Use of document.insertInLine is deprecated. Use insert instead.');
|
||||
return this.insert(position, text);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -293,7 +289,7 @@ var Document = function(textOrLines) {
|
|||
* @returns {Object} The position ({row, column}) of the last line of `text`. If the length of `text` is 0, this function simply returns `position`.
|
||||
*
|
||||
**/
|
||||
this.insertText = function(position, text) {
|
||||
this.insert = function(position, text) {
|
||||
|
||||
// Only detect new lines if the document has no line break yet.
|
||||
if (this.getLength() <= 1)
|
||||
|
|
@ -509,7 +505,7 @@ var Document = function(textOrLines) {
|
|||
this.remove(range);
|
||||
var end;
|
||||
if (text) {
|
||||
end = this.insertText(range.start, text);
|
||||
end = this.insert(range.start, text);
|
||||
}
|
||||
else {
|
||||
end = range.start;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module.exports = {
|
|||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertText({row: 0, column: 1}, "juhu");
|
||||
doc.insert({row: 0, column: 1}, "juhu");
|
||||
assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -126,7 +126,7 @@ module.exports = {
|
|||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertText({row: 0, column: 0}, "aa\nbb\ncc");
|
||||
doc.insert({row: 0, column: 0}, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -143,7 +143,7 @@ module.exports = {
|
|||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertText({row: 1, column: 2}, "aa\nbb\ncc");
|
||||
doc.insert({row: 1, column: 2}, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
@ -160,7 +160,7 @@ module.exports = {
|
|||
var deltas = [];
|
||||
doc.on("change", function(e) { deltas.push(e.data); });
|
||||
|
||||
doc.insertText({row: 0, column: 1}, "aa\nbb\ncc");
|
||||
doc.insert({row: 0, column: 1}, "aa\nbb\ncc");
|
||||
assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n"));
|
||||
|
||||
var d = deltas.concat();
|
||||
|
|
|
|||
|
|
@ -1127,12 +1127,6 @@ var EditSession = function(text, mode) {
|
|||
this.getTextRange = function(range) {
|
||||
return this.doc.getTextRange(range || this.selection.getRange());
|
||||
};
|
||||
|
||||
// Deprecated method retained for backwards compatibility.
|
||||
this.insert = function(position, text){
|
||||
console.warn('Use of editsession.insert is deprecated. Use the insertText method instead.');
|
||||
return this.insertText(position, text);
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts a block of `text` and the indicated `position`.
|
||||
|
|
@ -1142,8 +1136,8 @@ var EditSession = function(text, mode) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.insertText = function(position, text) {
|
||||
return this.doc.insertText(position, text);
|
||||
this.insert = function(position, text) {
|
||||
return this.doc.insert(position, text);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1356,7 +1350,7 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
}
|
||||
|
||||
toRange.end = this.insertText(toRange.start, text);
|
||||
toRange.end = this.insert(toRange.start, text);
|
||||
if (folds.length) {
|
||||
var oldStart = fromRange.start;
|
||||
var newStart = toRange.start;
|
||||
|
|
@ -1390,7 +1384,7 @@ var EditSession = function(text, mode) {
|
|||
this.indentRows = function(startRow, endRow, indentString) {
|
||||
indentString = indentString.replace(/\t/g, this.getTabString());
|
||||
for (var row=startRow; row<=endRow; row++)
|
||||
this.insertText({row: row, column:0}, indentString);
|
||||
this.insert({row: row, column:0}, indentString);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -649,7 +649,7 @@ module.exports = {
|
|||
var foldLines = session.$foldData;
|
||||
|
||||
function insert(row, column, text) {
|
||||
session.insertText({row: row, column: column}, text);
|
||||
session.insert({row: row, column: column}, text);
|
||||
|
||||
// Force the session to store all changes made to the document NOW
|
||||
// on the undoManager's queue. Otherwise we can't undo in separate
|
||||
|
|
@ -748,7 +748,7 @@ module.exports = {
|
|||
undoManager = session.getUndoManager(),
|
||||
foldLines = session.$foldData;
|
||||
function insert(row, column, text) {
|
||||
session.insertText({row: row, column: column}, text);
|
||||
session.insert({row: row, column: column}, text);
|
||||
// Force the session to store all changes made to the document NOW
|
||||
// on the undoManager's queue. Otherwise we can't undo in separate
|
||||
// steps later.
|
||||
|
|
|
|||
|
|
@ -822,19 +822,13 @@ var Editor = function(renderer, session) {
|
|||
if (this.$readOnly)
|
||||
return;
|
||||
this._emit("paste", text);
|
||||
this.insertText(text);
|
||||
this.insert(text);
|
||||
};
|
||||
|
||||
|
||||
this.execCommand = function(command, args) {
|
||||
this.commands.exec(command, this, args);
|
||||
};
|
||||
|
||||
// Deprecated method retained for backwards compatibility.
|
||||
this.insert = function(text){
|
||||
console.warn('Use of editor.insert is deprecated. Use the insertText method instead.');
|
||||
return this.insertText(text);
|
||||
};
|
||||
|
||||
/**
|
||||
* Inserts `text` into wherever the cursor is pointing.
|
||||
|
|
@ -842,7 +836,7 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
*
|
||||
**/
|
||||
this.insertText = function(text) {
|
||||
this.insert = function(text) {
|
||||
var session = this.session;
|
||||
var mode = session.getMode();
|
||||
var cursor = this.getCursorPosition();
|
||||
|
|
@ -888,7 +882,7 @@ var Editor = function(renderer, session) {
|
|||
var lineState = session.getState(cursor.row);
|
||||
var line = session.getLine(cursor.row);
|
||||
var shouldOutdent = mode.checkOutdent(lineState, line, text);
|
||||
var end = session.insertText(cursor, text);
|
||||
var end = session.insert(cursor, text);
|
||||
|
||||
if (transform && transform.selection) {
|
||||
if (transform.selection.length == 2) { // Transform relative to the current column
|
||||
|
|
@ -907,7 +901,7 @@ var Editor = function(renderer, session) {
|
|||
if (session.getDocument().isNewLine(text)) {
|
||||
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
|
||||
|
||||
session.insertText({row: cursor.row+1, column: 0}, lineIndent);
|
||||
session.insert({row: cursor.row+1, column: 0}, lineIndent);
|
||||
}
|
||||
if (shouldOutdent)
|
||||
mode.autoOutdent(lineState, session, cursor.row);
|
||||
|
|
@ -1280,7 +1274,7 @@ var Editor = function(renderer, session) {
|
|||
}
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
this.insertText("\n");
|
||||
this.insert("\n");
|
||||
this.moveCursorToPosition(cursor);
|
||||
};
|
||||
|
||||
|
|
@ -1379,7 +1373,7 @@ var Editor = function(renderer, session) {
|
|||
this.selection.setSelectionRange(range);
|
||||
indentString = "\t";
|
||||
}
|
||||
return this.insertText(indentString);
|
||||
return this.insert(indentString);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1531,7 +1525,7 @@ var Editor = function(renderer, session) {
|
|||
doc.duplicateLines(row, row);
|
||||
} else {
|
||||
var point = reverse ? range.start : range.end;
|
||||
var endPoint = doc.insertText(point, doc.getTextRange(range), false);
|
||||
var endPoint = doc.insert(point, doc.getTextRange(range), false);
|
||||
range.start = point;
|
||||
range.end = endPoint;
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ module.exports = {
|
|||
self.session1.setMode(new HtmlMode());
|
||||
|
||||
// 5. Try to type valid HTML
|
||||
self.session1.insertText({row: 0, column: 0}, "<html></html>");
|
||||
self.session1.insert({row: 0, column: 0}, "<html></html>");
|
||||
|
||||
setTimeout(function() {
|
||||
assert.equal(Object.keys(self.session1.getAnnotations()).length, 0);
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ module.exports = {
|
|||
var editor = new Editor(new MockRenderer(), new EditSession(["1234", "1234567890"]));
|
||||
|
||||
editor.navigateTo(0, 3);
|
||||
editor.insertText("juhu");
|
||||
editor.insert("juhu");
|
||||
|
||||
editor.navigateDown();
|
||||
assert.position(editor.getCursorPosition(), 1, 7);
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ var ElasticTabstopsLite = function(editor) {
|
|||
if (difference > 0) {
|
||||
// put the spaces after the tab and then delete the tab, so any insertion
|
||||
// points behave as expected
|
||||
this.$editor.session.getDocument().insertText({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
|
||||
this.$editor.session.getDocument().insert({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
|
||||
this.$editor.session.getDocument().removeInLine(row, it, it + 1);
|
||||
|
||||
bias += difference;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ exports.convertIndentation = function(session, ch, len) {
|
|||
|
||||
if (toInsert != match) {
|
||||
doc.removeInLine(i, 0, match.length);
|
||||
doc.insertText({row: i, column: 0}, toInsert);
|
||||
doc.insert({row: i, column: 0}, toInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ var actions = exports.actions = {
|
|||
if (param && param.length) {
|
||||
if (param.length > 1)
|
||||
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
|
||||
repeat(function() { editor.insertText(param); }, count || 1);
|
||||
repeat(function() { editor.insert(param); }, count || 1);
|
||||
editor.navigateLeft();
|
||||
}
|
||||
}
|
||||
|
|
@ -224,12 +224,12 @@ var actions = exports.actions = {
|
|||
var pos = editor.getCursorPosition();
|
||||
pos.column = editor.session.getLine(pos.row).length;
|
||||
var text = lang.stringRepeat("\n" + defaultReg.text, count || 1);
|
||||
editor.session.insertText(pos, text);
|
||||
editor.session.insert(pos, text);
|
||||
editor.moveCursorTo(pos.row + 1, 0);
|
||||
}
|
||||
else {
|
||||
editor.navigateRight();
|
||||
editor.insertText(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
editor.navigateLeft();
|
||||
}
|
||||
editor.setOverwrite(true);
|
||||
|
|
@ -245,11 +245,11 @@ var actions = exports.actions = {
|
|||
var pos = editor.getCursorPosition();
|
||||
pos.column = 0;
|
||||
var text = lang.stringRepeat(defaultReg.text + "\n", count || 1);
|
||||
editor.session.insertText(pos, text);
|
||||
editor.session.insert(pos, text);
|
||||
editor.moveCursorToPosition(pos);
|
||||
}
|
||||
else {
|
||||
editor.insertText(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
editor.insert(lang.stringRepeat(defaultReg.text, count || 1));
|
||||
}
|
||||
editor.setOverwrite(true);
|
||||
editor.selection.clearSelection();
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ module.exports = {
|
|||
|
||||
if (content.length) {
|
||||
editor.navigateLineEnd()
|
||||
editor.insertText(content);
|
||||
editor.insert(content);
|
||||
util.insertMode(editor);
|
||||
}
|
||||
}
|
||||
|
|
@ -562,9 +562,9 @@ module.exports = {
|
|||
if(row > 0) {
|
||||
editor.navigateUp();
|
||||
editor.navigateLineEnd()
|
||||
editor.insertText(content);
|
||||
editor.insert(content);
|
||||
} else {
|
||||
editor.session.insertText({row: 0, column: 0}, content);
|
||||
editor.session.insert({row: 0, column: 0}, content);
|
||||
editor.navigateUp();
|
||||
}
|
||||
util.insertMode(editor);
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ module.exports = {
|
|||
this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
assert.equal([" abc", " cde", " fg"].join("\n"), session.toString());
|
||||
|
||||
session.insertText({row: 0, column: 0}, " ");
|
||||
session.insert({row: 0, column: 0}, " ");
|
||||
this.mode.toggleCommentLines("start", session, 0, 2);
|
||||
assert.equal(["// abc", "// cde", "// fg"].join("\n"), session.toString());
|
||||
},
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ var Mode = function() {
|
|||
if (testRemove(line, i))
|
||||
return;
|
||||
if (!ignoreBlankLines || /\S/.test(line)) {
|
||||
doc.insertText({row: i, column: line.length}, lineCommentEnd);
|
||||
doc.insertText({row: i, column: minIndent}, lineCommentStart);
|
||||
doc.insert({row: i, column: line.length}, lineCommentEnd);
|
||||
doc.insert({row: i, column: minIndent}, lineCommentStart);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -138,9 +138,9 @@ var Mode = function() {
|
|||
var comment = function(line, i) {
|
||||
if (!ignoreBlankLines || /\S/.test(line)) {
|
||||
if (shouldInsertSpace(line, minIndent, minIndent))
|
||||
doc.insertText({row: i, column: minIndent}, commentWithSpace);
|
||||
doc.insert({row: i, column: minIndent}, commentWithSpace);
|
||||
else
|
||||
doc.insertText({row: i, column: minIndent}, lineCommentStart);
|
||||
doc.insert({row: i, column: minIndent}, lineCommentStart);
|
||||
}
|
||||
};
|
||||
var testRemove = function(line, i) {
|
||||
|
|
@ -244,8 +244,8 @@ var Mode = function() {
|
|||
} else {
|
||||
colDiff = comment.start.length
|
||||
startRow = range.start.row;
|
||||
session.insertText(range.end, comment.end);
|
||||
session.insertText(range.start, comment.start);
|
||||
session.insert(range.end, comment.end);
|
||||
session.insert(range.start, comment.start);
|
||||
}
|
||||
// todo: selection should have ended up in the right place automatically!
|
||||
if (initialRange.start.row == startRow)
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ function DragdropHandler(mouseHandler) {
|
|||
var dropData = dataTransfer.getData('Text');
|
||||
range = {
|
||||
start: dragCursor,
|
||||
end: editor.session.insertText(dragCursor, dropData)
|
||||
end: editor.session.insert(dragCursor, dropData)
|
||||
};
|
||||
editor.focus();
|
||||
dragOperation = null;
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ var Editor = require("./editor").Editor;
|
|||
|
||||
this._signal("paste", text);
|
||||
if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
|
||||
return this.insertText(text);
|
||||
return this.insert(text);
|
||||
|
||||
var lines = text.split(/\r\n|\r|\n/);
|
||||
var ranges = this.selection.rangeList.ranges;
|
||||
|
|
@ -557,7 +557,7 @@ var Editor = require("./editor").Editor;
|
|||
if (!range.isEmpty())
|
||||
this.session.remove(range);
|
||||
|
||||
this.session.insertText(range.start, lines[i]);
|
||||
this.session.insert(range.start, lines[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -742,7 +742,7 @@ var Editor = require("./editor").Editor;
|
|||
}
|
||||
var lines = this.session.removeFullLines(fr, lr);
|
||||
lines = this.$reAlignText(lines, guessRange);
|
||||
this.session.insertText({row: fr, column: 0}, lines.join("\n") + "\n");
|
||||
this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
|
||||
if (!guessRange) {
|
||||
range.start.column = 0;
|
||||
range.end.column = lines[lines.length - 1].length;
|
||||
|
|
@ -778,7 +778,7 @@ var Editor = require("./editor").Editor;
|
|||
var l = maxCol - p.column;
|
||||
var d = spaceOffsets[i] - minSpace;
|
||||
if (l > d)
|
||||
session.insertText(p, lang.stringRepeat(" ", l - d));
|
||||
session.insert(p, lang.stringRepeat(" ", l - d));
|
||||
else
|
||||
session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
"test: find lines matching" : function() {
|
||||
editor.session.insertText({row: 0, column: 0}, 'abc\ndef\nxyz\nbcxbc');
|
||||
editor.session.insert({row: 0, column: 0}, 'abc\ndef\nxyz\nbcxbc');
|
||||
var result = occur.matchingLines(editor.session, {needle: 'bc'}),
|
||||
expected = [{row: 0, content: 'abc'}, {row: 3, content: 'bcxbc'}];
|
||||
assert.deepEqual(result, expected);
|
||||
|
|
@ -63,7 +63,7 @@ module.exports = {
|
|||
|
||||
"test: display occurrences" : function() {
|
||||
var text = 'abc\ndef\nxyz\nbcx\n';
|
||||
editor.session.insertText({row: 0, column: 0}, text);
|
||||
editor.session.insert({row: 0, column: 0}, text);
|
||||
occur.displayOccurContent(editor, {needle: 'bc'});
|
||||
assert.equal(editor.getValue(), 'abc\nbcx');
|
||||
occur.displayOriginalContent(editor);
|
||||
|
|
@ -72,7 +72,7 @@ module.exports = {
|
|||
|
||||
"test: original position from occur doc" : function() {
|
||||
var text = 'abc\ndef\nxyz\nbcx\n';
|
||||
editor.session.insertText({row: 0, column: 0}, text);
|
||||
editor.session.insert({row: 0, column: 0}, text);
|
||||
occur.displayOccurContent(editor, {needle: 'bc'});
|
||||
assert.equal(editor.getValue(), 'abc\nbcx');
|
||||
var pos = occur.occurToOriginalPosition(editor.session, {row: 1, column: 2});
|
||||
|
|
@ -82,7 +82,7 @@ module.exports = {
|
|||
"test: occur command" : function() {
|
||||
// setup
|
||||
var text = 'hel\nlo\n\nwo\nrld\n';
|
||||
editor.session.insertText({row: 0, column: 0}, text);
|
||||
editor.session.insert({row: 0, column: 0}, text);
|
||||
editor.commands.addCommand(occurStartCommand);
|
||||
|
||||
// run occur for lines including 'o'
|
||||
|
|
@ -106,7 +106,7 @@ module.exports = {
|
|||
"test: occur navigation" : function() {
|
||||
// setup
|
||||
var text = 'hel\nlo\n\nwo\nrld\n';
|
||||
editor.session.insertText({row: 0, column: 0}, text);
|
||||
editor.session.insert({row: 0, column: 0}, text);
|
||||
editor.commands.addCommand(occurStartCommand);
|
||||
editor.moveCursorToPosition({row: 1, column: 1});
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ module.exports = {
|
|||
"test: recursive occur" : function() {
|
||||
// setup
|
||||
var text = 'x\nabc1\nx\nabc2\n';
|
||||
editor.session.insertText({row: 0, column: 0}, text);
|
||||
editor.session.insert({row: 0, column: 0}, text);
|
||||
editor.commands.addCommand(occurStartCommand);
|
||||
|
||||
// orig -> occur1
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ module.exports = {
|
|||
new PlaceHolder(session, 1, {row: 0, column: 4}, [{row: 1, column: 12}, {row: 1, column: 15}]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insertText('b');
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);");
|
||||
editor.insertText('cd');
|
||||
editor.insert('cd');
|
||||
assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(abcd, abcd);");
|
||||
editor.remove('left');
|
||||
editor.remove('left');
|
||||
|
|
@ -70,7 +70,7 @@ module.exports = {
|
|||
new PlaceHolder(session, 1, {row: 0, column: 4}, [{row: 1, column: 12}, {row: 1, column: 15}]);
|
||||
|
||||
editor.moveCursorTo(2, 0);
|
||||
editor.insertText('b');
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);\nb");
|
||||
},
|
||||
|
||||
|
|
@ -81,12 +81,12 @@ module.exports = {
|
|||
var p = new PlaceHolder(session, 1, {row: 0, column: 4}, [{row: 1, column: 12}, {row: 1, column: 15}]);
|
||||
|
||||
editor.moveCursorTo(0, 4);
|
||||
editor.insertText('$');
|
||||
editor.insert('$');
|
||||
assert.equal(session.doc.getValue(), "var $a = 10;\nconsole.log($a, $a);");
|
||||
editor.moveCursorTo(0, 4);
|
||||
// Have to put this in a setTimeout because the anchor is only fixed later.
|
||||
setTimeout(function() {
|
||||
editor.insertText('v');
|
||||
editor.insert('v');
|
||||
assert.equal(session.doc.getValue(), "var v$a = 10;\nconsole.log(v$a, v$a);");
|
||||
next();
|
||||
}, 10);
|
||||
|
|
@ -99,10 +99,10 @@ module.exports = {
|
|||
var p = new PlaceHolder(session, 1, {row: 0, column: 4}, [{row: 1, column: 12}, {row: 1, column: 15}]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insertText('b');
|
||||
editor.insert('b');
|
||||
assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);");
|
||||
p.detach();
|
||||
editor.insertText('cd');
|
||||
editor.insert('cd');
|
||||
assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(ab, ab);");
|
||||
},
|
||||
|
||||
|
|
@ -136,8 +136,8 @@ module.exports = {
|
|||
var p = new PlaceHolder(session, 1, {row: 0, column: 4}, [{row: 1, column: 12}, {row: 1, column: 15}]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.insertText('b');
|
||||
editor.insertText('cd');
|
||||
editor.insert('b');
|
||||
editor.insert('cd');
|
||||
editor.remove('left');
|
||||
assert.equal(session.doc.getValue(), "var abc = 10;\nconsole.log(abc, abc);");
|
||||
// Wait a little for the changes to enter the undo stack
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue