mirror of https://github.com/shadowfacts/type.git
Fix delete not working correctly in the middle of lines
This commit is contained in:
parent
bfac331421
commit
b770fd1101
6
main.js
6
main.js
|
@ -51,7 +51,7 @@ document.addEventListener("keydown", (event) => {
|
||||||
moveToEndOfPreviousLine();
|
moveToEndOfPreviousLine();
|
||||||
} else { // move back 1 char
|
} else { // move back 1 char
|
||||||
let line = editor.doc.getLine(pos.line);
|
let line = editor.doc.getLine(pos.line);
|
||||||
if (line.hasPreceedingWhiteSpace()) {
|
if (line.hasOnlyWhiteSpaceBeforeIndex(pos.ch)) {
|
||||||
moveToEndOfPreviousLine();
|
moveToEndOfPreviousLine();
|
||||||
} else {
|
} else {
|
||||||
editor.setCursor({ line: pos.line, ch: pos.ch - 1 });
|
editor.setCursor({ line: pos.line, ch: pos.ch - 1 });
|
||||||
|
@ -126,6 +126,6 @@ function updateIncompleteMark() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
String.prototype.hasPreceedingWhiteSpace = function() {
|
String.prototype.hasOnlyWhiteSpaceBeforeIndex = function(index) {
|
||||||
return this.indexOf(this.trim()) != 0;
|
return this.substring(index) == this.trim();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue