mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Merge pull request #18114 from overleaf/em-resync-comments
Handle comments when resyncing history GitOrigin-RevId: cd848fbd91f017a0a66e46df5c009bd16498d154
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user