Fix delete not working correctly in the middle of lines

This commit is contained in:
Shadowfacts 2016-09-28 18:49:24 -04:00
parent bfac331421
commit b770fd1101
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 3 deletions

View File

@ -51,7 +51,7 @@ document.addEventListener("keydown", (event) => {
moveToEndOfPreviousLine();
} else { // move back 1 char
let line = editor.doc.getLine(pos.line);
if (line.hasPreceedingWhiteSpace()) {
if (line.hasOnlyWhiteSpaceBeforeIndex(pos.ch)) {
moveToEndOfPreviousLine();
} else {
editor.setCursor({ line: pos.line, ch: pos.ch - 1 });
@ -126,6 +126,6 @@ function updateIncompleteMark() {
});
}
String.prototype.hasPreceedingWhiteSpace = function() {
return this.indexOf(this.trim()) != 0;
String.prototype.hasOnlyWhiteSpaceBeforeIndex = function(index) {
return this.substring(index) == this.trim();
};