Skip to content
Snippets Groups Projects
Commit e0d72cc3 authored by chris's avatar chris Committed by john
Browse files

check if annotation is comment when creating a new one instead of command states are active

parent 1e3f7084
No related branches found
No related tags found
No related merge requests found
......@@ -48,23 +48,24 @@ class CommentsProvider extends TocProvider {
updateActiveEntry () {
// if the new selection is not a comment, remove the active entry (if one)
// if the new selection is a comment, make it activeEntry
const selectionState = this.config.documentSession.getSelectionState()
const commentAnnotations = selectionState.getAnnotationsForType('comment')
const activeEntry = this.getActiveEntry()
const commentState = this.getCommentState()
// const commentState = this.getCommentState()
// TODO why on any mode except delete active is false???
if (commentState.mode === 'fuse') commentState.active = true
console.log('provider commands', commentState)
let onComment = commentState.active // is current selection on a comment
if (!onComment && !activeEntry) return
// if (commentState.mode === 'fuse') commentState.active = true
// commentState.active = true // TODO TEMP
// let onComment = commentState.active // is current selection on a comment
console.log('commentAnnotationscommentAnnotationscommentAnnotations', commentAnnotations)
if (commentAnnotations.length === 0 && !activeEntry) return
if (!onComment && activeEntry) {
if (commentAnnotations.length === 0 && activeEntry) {
this.removeEmptyComments()
this.removeActiveEntry()
return
}
const activeComment = this.getActiveComment()
console.log('whichhhh', activeComment.id)
if (activeEntry === activeComment.id) return
this.setActiveEntry(activeComment.id)
}
......@@ -147,11 +148,19 @@ class CommentsProvider extends TocProvider {
getActiveComment () {
const selectionState = this.config.documentSession.getSelectionState()
const commentAnnotations = selectionState.getAnnotationsForType('comment')
console.log('selection', this.config.documentSession.getSelection())
const count = commentAnnotations.length - 1
console.log(count)
const commentState = this.getCommentState()
console.log('commentState', commentState)
console.log('all comments', commentAnnotations)
// TODO -- what happens with multiple comments on the same cursor position?
return commentAnnotations[count]
switch (commentState.mode) {
case 'delete':
return commentAnnotations[0]
case 'fuse':
const count = commentAnnotations.length - 1
return commentAnnotations[count]
}
}
getComments () {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment