Merge pull request #18114 from overleaf/em-resync-comments

Handle comments when resyncing history

GitOrigin-RevId: cd848fbd91f017a0a66e46df5c009bd16498d154
This commit is contained in:
Eric Mc Sween
2024-05-03 09:27:39 -04:00
committed by Copybot
parent 0c20c86878
commit b75ba32774
10 changed files with 640 additions and 107 deletions

View File

@@ -7,6 +7,7 @@ const ChangeRequest = require('./lib/change_request')
const ChangeNote = require('./lib/change_note')
const Chunk = require('./lib/chunk')
const ChunkResponse = require('./lib/chunk_response')
const Comment = require('./lib/comment')
const DeleteCommentOperation = require('./lib/operation/delete_comment_operation')
const File = require('./lib/file')
const FileMap = require('./lib/file_map')
@@ -48,6 +49,7 @@ exports.ChangeRequest = ChangeRequest
exports.ChangeNote = ChangeNote
exports.Chunk = Chunk
exports.ChunkResponse = ChunkResponse
exports.Comment = Comment
exports.DeleteCommentOperation = DeleteCommentOperation
exports.File = File
exports.FileMap = FileMap

View File

@@ -21,6 +21,15 @@ class CommentList {
return this.comments.values()
}
/**
* Returns the contents of this list in an array
*
* @returns {Comment[]}
*/
toArray() {
return Array.from(this)
}
/**
* Return the length of the comment list
*

View File

@@ -25,6 +25,16 @@ class Range {
return this.pos + this.length
}
/**
* Is this range equal to the given range?
*
* @param {Range} other
* @returns {boolean}
*/
equals(other) {
return this.pos === other.pos && this.length === other.length
}
/**
* @param {Range} range
* @returns {boolean}

View File

@@ -128,6 +128,12 @@ describe('commentList', function () {
])
})
it('should be iterable', function () {
const comment = new Comment('comm1', [new Range(5, 10)])
const commentList = new CommentList([comment])
expect(Array.from(commentList)).to.deep.equal([comment])
})
describe('inserting a comment between ranges', function () {
it('should expand comment on the left', function () {
const commentList = CommentList.fromRaw([