This commit is contained in:
Fabian Jakobs 2011-12-08 18:51:28 +01:00
commit 5f03c6b48c
7 changed files with 112 additions and 49 deletions

View file

@ -5491,19 +5491,31 @@ var Selection = function(session) {
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
var fold;
if (fold = this.session.getFoldAt(row, column, 1)) {
// skip folds
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
this.moveCursorTo(fold.end.row, fold.end.column);
return;
} else if (column == line.length) {
this.moveCursorRight();
return;
}
else if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
// first skip space
if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
}
else if (match = this.session.tokenRe.exec(rightOfCursor)) {
// if at line end proceed with next line
if (column >= line.length) {
this.moveCursorTo(row, line.length);
this.moveCursorRight();
if (row < this.doc.getLength() - 1)
this.moveCursorWordRight();
return;
}
// advance to the end of the next token
if (match = this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@ -5515,32 +5527,41 @@ var Selection = function(session) {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
// skip folds
var fold;
if (fold = this.session.getFoldAt(row, column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
return;
}
if (column == 0) {
this.moveCursorLeft();
return;
}
var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) {
str = this.doc.getLine(row).substring(0, column)
}
var leftOfCursor = lang.stringReverse(str);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
// skip whitespace
if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
}
else if (match = this.session.tokenRe.exec(leftOfCursor)) {
// if at begin of the line proceed in line above
if (column <= 0) {
this.moveCursorTo(row, 0);
this.moveCursorLeft();
if (row > 0)
this.moveCursorWordLeft();
return;
}
// move to the begin of the word
if (match = this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@
Ace
version 0.2.0
commit 6a6c4c4c1559f660210131fe83f60eb2beed8091
commit 9cb05c2e56c866be5da702c0d920dd16064d53a0
-->

View file

@ -7396,19 +7396,31 @@ var Selection = function(session) {
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
var fold;
if (fold = this.session.getFoldAt(row, column, 1)) {
// skip folds
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
this.moveCursorTo(fold.end.row, fold.end.column);
return;
} else if (column == line.length) {
this.moveCursorRight();
return;
}
else if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
// first skip space
if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
}
else if (match = this.session.tokenRe.exec(rightOfCursor)) {
// if at line end proceed with next line
if (column >= line.length) {
this.moveCursorTo(row, line.length);
this.moveCursorRight();
if (row < this.doc.getLength() - 1)
this.moveCursorWordRight();
return;
}
// advance to the end of the next token
if (match = this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@ -7420,32 +7432,41 @@ var Selection = function(session) {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
// skip folds
var fold;
if (fold = this.session.getFoldAt(row, column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
return;
}
if (column == 0) {
this.moveCursorLeft();
return;
}
var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) {
str = this.doc.getLine(row).substring(0, column)
}
var leftOfCursor = lang.stringReverse(str);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
// skip whitespace
if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
}
else if (match = this.session.tokenRe.exec(leftOfCursor)) {
// if at begin of the line proceed in line above
if (column <= 0) {
this.moveCursorTo(row, 0);
this.moveCursorLeft();
if (row > 0)
this.moveCursorWordLeft();
return;
}
// move to the begin of the word
if (match = this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}

File diff suppressed because one or more lines are too long

View file

@ -7390,19 +7390,31 @@ var Selection = function(session) {
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
var fold;
if (fold = this.session.getFoldAt(row, column, 1)) {
// skip folds
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
this.moveCursorTo(fold.end.row, fold.end.column);
return;
} else if (column == line.length) {
this.moveCursorRight();
return;
}
else if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
// first skip space
if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
}
else if (match = this.session.tokenRe.exec(rightOfCursor)) {
// if at line end proceed with next line
if (column >= line.length) {
this.moveCursorTo(row, line.length);
this.moveCursorRight();
if (row < this.doc.getLength() - 1)
this.moveCursorWordRight();
return;
}
// advance to the end of the next token
if (match = this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
@ -7414,32 +7426,41 @@ var Selection = function(session) {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
// skip folds
var fold;
if (fold = this.session.getFoldAt(row, column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
return;
}
if (column == 0) {
this.moveCursorLeft();
return;
}
var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) {
str = this.doc.getLine(row).substring(0, column)
}
var leftOfCursor = lang.stringReverse(str);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
// skip whitespace
if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
}
else if (match = this.session.tokenRe.exec(leftOfCursor)) {
// if at begin of the line proceed in line above
if (column <= 0) {
this.moveCursorTo(row, 0);
this.moveCursorLeft();
if (row > 0)
this.moveCursorWordLeft();
return;
}
// move to the begin of the word
if (match = this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}

File diff suppressed because one or more lines are too long