small cleanup
This commit is contained in:
parent
0a14538bbe
commit
3dd051f857
2 changed files with 26 additions and 30 deletions
|
|
@ -35,9 +35,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict"
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"x": {
|
||||
operator: {
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict"
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var util = require("./util");
|
||||
|
||||
|
|
@ -56,36 +56,26 @@ function Motion(getRange, type){
|
|||
else
|
||||
var reverse = type;
|
||||
|
||||
this.nav = function(editor) {
|
||||
var r = getRange(editor);
|
||||
if (!r)
|
||||
this.nav = function(editor, range, count, param) {
|
||||
range = getRange(editor, range, count, param);
|
||||
if (!range)
|
||||
return;
|
||||
if (!r.end)
|
||||
var a = r;
|
||||
else if (reverse)
|
||||
var a = r.start;
|
||||
else
|
||||
var a = r.end;
|
||||
var pos = range.end ? range : range[reverse ? "start" : "end"];
|
||||
|
||||
editor.clearSelection();
|
||||
editor.moveCursorTo(a.row, a.column);
|
||||
}
|
||||
this.sel = function(editor){
|
||||
var r = getRange(editor);
|
||||
if (!r)
|
||||
editor.moveCursorTo(pos.row, pos.column);
|
||||
};
|
||||
this.sel = function(editor, range, count, param){
|
||||
range = getRange(editor, range, count, param);
|
||||
if (!range)
|
||||
return;
|
||||
if (extend)
|
||||
return editor.selection.setSelectionRange(r);
|
||||
return editor.selection.setSelectionRange(range);
|
||||
|
||||
if (!r.end)
|
||||
var a = r;
|
||||
else if (reverse)
|
||||
var a = r.start;
|
||||
else
|
||||
var a = r.end;
|
||||
var pos = range.end ? range : range[reverse ? "start" : "end"];
|
||||
|
||||
editor.selection.selectTo(a.row, a.column);
|
||||
}
|
||||
editor.selection.selectTo(pos.row, pos.column);
|
||||
};
|
||||
}
|
||||
|
||||
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
||||
|
|
@ -98,8 +88,8 @@ var StringStream = function(editor, cursor) {
|
|||
this.row = cursor.row;
|
||||
this.col = cursor.column;
|
||||
var line = editor.session.getLine(this.row);
|
||||
var maxRow = editor.session.getLength()
|
||||
this.ch = line[this.col] || '\n'
|
||||
var maxRow = editor.session.getLength();
|
||||
this.ch = line[this.col] || '\n';
|
||||
this.skippedLines = 0;
|
||||
|
||||
this.next = function() {
|
||||
|
|
@ -187,7 +177,7 @@ module.exports = {
|
|||
else
|
||||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row}
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"b": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
|
@ -505,6 +495,9 @@ module.exports = {
|
|||
editor.gotoLine(count || 0);
|
||||
case "U":
|
||||
editor.gotoLine(count || 0);
|
||||
case "$":
|
||||
editor.navigateLineEnd();
|
||||
break;
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
|
|
@ -517,6 +510,9 @@ module.exports = {
|
|||
break;
|
||||
case "g":
|
||||
editor.selection.selectTo(count || 0, 0);
|
||||
case "$":
|
||||
editor.selection.selectLineEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -528,7 +524,7 @@ module.exports = {
|
|||
content += "\n";
|
||||
|
||||
if (content.length) {
|
||||
editor.navigateLineEnd()
|
||||
editor.navigateLineEnd();
|
||||
editor.insert(content);
|
||||
util.insertMode(editor);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue