Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changeset: Various minor cleanups and fixes #5268

Merged
merged 22 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4a65c2c
Changeset: Unexport unnecessarily exported functions
rhansen Mar 21, 2021
b29e594
Changeset: Factor out duplicate code
rhansen Oct 16, 2021
7fa9b07
Changeset: Invert conditions to improve readability
rhansen Sep 27, 2021
37bb297
Changeset: Improve logged error message
rhansen Mar 5, 2021
7ec0d5f
Changeset: Remove unnecessary `linesApplySplice()`
rhansen Mar 21, 2021
18a6b72
Changeset: Only pass strings to `parseNum()`
rhansen Oct 21, 2021
02ef78e
Changeset: Make sure `opOut` is cleared
rhansen Oct 2, 2021
94f5507
Changeset: Improve `copyOp()` API
rhansen Oct 2, 2021
1955e7b
Changeset: Replace output params with return values
rhansen Oct 13, 2021
44d9973
Changeset: Check `.hasNext()` before calling `.next()`
rhansen Sep 30, 2021
ca5bddd
Changeset: Use `break` instead of `done` variable
rhansen Nov 9, 2021
42d4d82
Changeset: Refactor `appendATextToAssembler()` for readability
rhansen Mar 21, 2021
efeb69b
Changeset: Simplify `slicerZipperFunc()`
rhansen Mar 23, 2021
097f262
Changeset: Add sanity checks to `slicerZipperFunc()`
rhansen Mar 23, 2021
0ae8fb1
Changeset: Use string concatenation instead of array join
rhansen Oct 11, 2021
9c17b03
Changeset: Require Op opcode and attribs to be strings
rhansen Oct 3, 2021
6d5b737
Changeset: Replace `.apply()` with spread operator
rhansen Oct 11, 2021
1cad5d8
Changeset: Use `for...of` iteration to improve readability
rhansen Oct 11, 2021
9401ae8
Changeset: Sort attributes by keys, not full string rep
rhansen Oct 12, 2021
b62534a
Changeset: Use Maps to simplify attribute processing
rhansen Oct 12, 2021
4f4a775
Changeset: Improve handling of missing attribute in old pool
rhansen Oct 25, 2021
1bbe0d9
Changeset: Use `in` check to help TypeScript narrowing
rhansen Oct 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
* Changes to the `src/static/js/Changeset.js` library:
* `opIterator()`: The unused start index parameter has been removed, as has
the unused `lastIndex()` method on the returned object.
* Several functions that should have never been public are no longer
exported: `applyZip()`, `assert()`, `clearOp()`, `cloneOp()`, `copyOp()`,
`error()`, `followAttributes()`, `opString()`, `stringOp()`,
`textLinesMutator()`, `toBaseTen()`, `toSplices()`.

### Notable enhancements

Expand Down
16 changes: 7 additions & 9 deletions src/node/utils/padDiff.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ PadDiff.prototype._createDiffAtext = async function () {
if (superChangeset == null) {
superChangeset = changeset;
} else {
superChangeset = Changeset.composeWithDeletions(superChangeset, changeset, this._pad.pool);
superChangeset = Changeset.compose(superChangeset, changeset, this._pad.pool);
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
let curChar = 0;
let curLineOpIter = null;
let curLineOpIterLine;
const curLineNextOp = Changeset.newOp('+');
let curLineNextOp = Changeset.newOp('+');

const unpacked = Changeset.unpack(cs);
const csIter = Changeset.opIterator(unpacked.ops);
Expand All @@ -285,15 +285,13 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
curLineOpIter = Changeset.opIterator(aLinesGet(curLine));
curLineOpIterLine = curLine;
let indexIntoLine = 0;
let done = false;
while (!done) {
curLineOpIter.next(curLineNextOp);
while (curLineOpIter.hasNext()) {
curLineNextOp = curLineOpIter.next();
if (indexIntoLine + curLineNextOp.chars >= curChar) {
curLineNextOp.chars -= (curChar - indexIntoLine);
done = true;
} else {
indexIntoLine += curLineNextOp.chars;
break;
}
indexIntoLine += curLineNextOp.chars;
}
}

Expand All @@ -307,7 +305,7 @@ PadDiff.prototype._createDeletionChangeset = function (cs, startAText, apool) {
}

if (!curLineNextOp.chars) {
curLineOpIter.next(curLineNextOp);
curLineNextOp = curLineOpIter.hasNext() ? curLineOpIter.next() : Changeset.newOp();
}

const charsToUse = Math.min(numChars, curLineNextOp.chars);
Expand Down
Loading