fix r+enter, add ,;
This commit is contained in:
parent
3fdfb76797
commit
2eabebccaa
2 changed files with 53 additions and 16 deletions
|
|
@ -90,6 +90,8 @@ var actions = exports.actions = {
|
||||||
param: true,
|
param: true,
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
if (param && param.length) {
|
if (param && param.length) {
|
||||||
|
if (param.length > 1)
|
||||||
|
param = param == "return" ? "\n" : param == "tab" ? "\t" : param;
|
||||||
repeat(function() { editor.insert(param); }, count || 1);
|
repeat(function() { editor.insert(param); }, count || 1);
|
||||||
editor.navigateLeft();
|
editor.navigateLeft();
|
||||||
}
|
}
|
||||||
|
|
@ -286,26 +288,20 @@ var actions = exports.actions = {
|
||||||
var val = ":";
|
var val = ":";
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
val = ".,.+" + count + val;
|
val = ".,.+" + count + val;
|
||||||
if (editor.cmdLine) {
|
if (editor.showCommandLine)
|
||||||
editor.cmdLine.setValue(val, 1);
|
editor.showCommandLine(val);
|
||||||
editor.cmdLine.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/": {
|
"/": {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
if (editor.cmdLine) {
|
if (editor.showCommandLine)
|
||||||
editor.cmdLine.setValue("/", 1);
|
editor.showCommandLine("/");
|
||||||
editor.cmdLine.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"?": {
|
"?": {
|
||||||
fn: function(editor, range, count, param) {
|
fn: function(editor, range, count, param) {
|
||||||
if (editor.cmdLine) {
|
if (editor.showCommandLine)
|
||||||
editor.cmdLine.setValue("?", 1);
|
editor.showCommandLine("?");
|
||||||
editor.cmdLine.focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
".": {
|
".": {
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ function find(editor, needle, dir) {
|
||||||
|
|
||||||
var Range = require("../../../range").Range;
|
var Range = require("../../../range").Range;
|
||||||
|
|
||||||
|
var LAST_SEARCH_MOTION = {};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"w": new Motion(function(editor) {
|
"w": new Motion(function(editor) {
|
||||||
var str = new StringStream(editor);
|
var str = new StringStream(editor);
|
||||||
|
|
@ -381,7 +383,9 @@ module.exports = {
|
||||||
"f": new Motion({
|
"f": new Motion({
|
||||||
param: true,
|
param: true,
|
||||||
handlesCount: true,
|
handlesCount: true,
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||||
|
if (!isRepeat)
|
||||||
|
LAST_SEARCH_MOTION = {ch: "f", param: param};
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||||
|
|
||||||
|
|
@ -394,7 +398,9 @@ module.exports = {
|
||||||
"F": new Motion({
|
"F": new Motion({
|
||||||
param: true,
|
param: true,
|
||||||
handlesCount: true,
|
handlesCount: true,
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||||
|
if (!isRepeat)
|
||||||
|
LAST_SEARCH_MOTION = {ch: "F", param: param};
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||||
|
|
||||||
|
|
@ -407,10 +413,15 @@ module.exports = {
|
||||||
"t": new Motion({
|
"t": new Motion({
|
||||||
param: true,
|
param: true,
|
||||||
handlesCount: true,
|
handlesCount: true,
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||||
|
if (!isRepeat)
|
||||||
|
LAST_SEARCH_MOTION = {ch: "t", param: param};
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||||
|
|
||||||
|
if (isRepeat && column == 0 && !(count > 1))
|
||||||
|
var column = util.getRightNthChar(editor, cursor, param, 2);
|
||||||
|
|
||||||
if (typeof column === "number") {
|
if (typeof column === "number") {
|
||||||
cursor.column += column + (isSel ? 1 : 0);
|
cursor.column += column + (isSel ? 1 : 0);
|
||||||
return cursor;
|
return cursor;
|
||||||
|
|
@ -420,16 +431,46 @@ module.exports = {
|
||||||
"T": new Motion({
|
"T": new Motion({
|
||||||
param: true,
|
param: true,
|
||||||
handlesCount: true,
|
handlesCount: true,
|
||||||
getPos: function(editor, range, count, param, isSel) {
|
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||||
|
if (!isRepeat)
|
||||||
|
LAST_SEARCH_MOTION = {ch: "T", param: param};
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||||
|
|
||||||
|
if (isRepeat && column == 0 && !(count > 1))
|
||||||
|
var column = util.getLeftNthChar(editor, cursor, param, 2);
|
||||||
|
|
||||||
if (typeof column === "number") {
|
if (typeof column === "number") {
|
||||||
cursor.column -= column;
|
cursor.column -= column;
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
";": new Motion({
|
||||||
|
handlesCount: true,
|
||||||
|
getPos: function(editor, range, count, param, isSel) {
|
||||||
|
var ch = LAST_SEARCH_MOTION.ch;
|
||||||
|
if (!ch)
|
||||||
|
return;
|
||||||
|
return module.exports[ch].getPos(
|
||||||
|
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
",": new Motion({
|
||||||
|
handlesCount: true,
|
||||||
|
getPos: function(editor, range, count, param, isSel) {
|
||||||
|
var ch = LAST_SEARCH_MOTION.ch;
|
||||||
|
if (!ch)
|
||||||
|
return;
|
||||||
|
var up = ch.toUpperCase();
|
||||||
|
ch = ch === up ? ch.toLowerCase() : up;
|
||||||
|
|
||||||
|
return module.exports[ch].getPos(
|
||||||
|
editor, range, count, LAST_SEARCH_MOTION.param, isSel, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
"^": {
|
"^": {
|
||||||
nav: function(editor) {
|
nav: function(editor) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue