This commit is contained in:
Toks
2013-04-11 19:11:04 -04:00
parent ee5310782b
commit 5bce52e6f1

View File

@@ -55,25 +55,25 @@
var a = $field.get(0).selectionStart; var a = $field.get(0).selectionStart;
var b = $field.get(0).selectionStart; var b = $field.get(0).selectionStart;
if ((a > 0) && (a < (n - 1)) && (string[a] !== " ") && (string[a - 1] === " ")) { if ((a > 0) && (a < (n - 1)) && (!/\s/.test(string[a])) && (/\s/.test(string[a - 1]))) {
// 4 is the only case where we need to scan forward. in all other cases we // 4 is the only case where we need to scan forward. in all other cases we
// can drag a backwards, and then drag b forwards. // can drag a backwards, and then drag b forwards.
while ((b < n) && (string[b] !== " ")) { while ((b < n) && (!/\s/.test(string[b]))) {
b++; b++;
} }
} else { } else {
while ((a > 0) && ((string[a] === " ") || (string[a] === undefined))) { while ((a > 0) && ((/\s/.test(string[a])) || (string[a] === undefined))) {
a--; a--;
b--; b--;
} }
while ((a > 0) && (string[a - 1] !== " ")) { while ((a > 0) && (!/\s/.test(string[a - 1]))) {
a--; a--;
b--; b--;
} }
while ((b < (n - 1)) && (string[b] !== " ")) { while ((b < (n - 1)) && (!/\s/.test(string[b]))) {
b++; b++;
} }
} }