soto: mutate cursor for tab complete inserts

This changes sole.js to handle cursor behaviour for tabbing.

It does so by overriding the cursor position in transpose if it's greater
than it expects. This could produce errant results if other sole apps
use insert behind text, but that seems like an edge case. Flagged for
future with a comment.
This commit is contained in:
Matilde Park 2019-12-04 12:54:10 -05:00
parent 5e42e796e7
commit 3c541ca567
2 changed files with 8 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -57,9 +57,14 @@ export class Share {
switch (Object.keys(dex)[0]) {
case 'del': if (at < dex.del) { dex.del++; } break;
case 'ins': if ((at < dex.ins.at) ||
((at === dex.ins.at) && !(cha <= dex.ins.cha))) {
((at === dex.ins.at) && !(cha <= dex.ins.cha))) {
dex.ins.at++;
} break;
}
else if (at >= dex.ins.at) {
dex.ins.at = at; //NOTE possibly unpredictable behaviour
dex.ins.at++; // for sole inserts that aren't tabs
}
break;
}
return dex;
default: throw `%sole-edit -lost.${str(sin)}`;