|
|
@@ -216,25 +216,31 @@ define [
|
|
|
$scope.$broadcast "review-panel:recalculate-screen-positions"
|
|
|
$scope.$broadcast "review-panel:layout"
|
|
|
|
|
|
- $scope.$on "editor:focus:changed", (e, cursor_offset, selection) ->
|
|
|
+ $scope.$on "editor:focus:changed", (e, selection_offset_start, selection_offset_end, selection) ->
|
|
|
doc_id = $scope.editor.open_doc_id
|
|
|
entries = getDocEntries(doc_id)
|
|
|
|
|
|
- if !selection
|
|
|
- delete entries["add-comment"]
|
|
|
- else
|
|
|
- entries["add-comment"] = {
|
|
|
- type: "add-comment"
|
|
|
- offset: cursor_offset
|
|
|
- }
|
|
|
+ delete entries["add-comment"]
|
|
|
+ if selection
|
|
|
+ # Only show add comment if we're not already overlapping one
|
|
|
+ overlapping_comment = false
|
|
|
+ for id, entry of entries
|
|
|
+ if entry.type == "comment" and not $scope.reviewPanel.resolvedThreadIds[entry.thread_id]
|
|
|
+ unless entry.offset >= selection_offset_end or entry.offset + entry.content.length <= selection_offset_start
|
|
|
+ overlapping_comment = true
|
|
|
+ if !overlapping_comment
|
|
|
+ entries["add-comment"] = {
|
|
|
+ type: "add-comment"
|
|
|
+ offset: selection_offset_start
|
|
|
+ }
|
|
|
|
|
|
for id, entry of entries
|
|
|
- if entry.type == "comment" and not entry.resolved
|
|
|
- entry.focused = (entry.offset <= cursor_offset <= entry.offset + entry.content.length)
|
|
|
+ if entry.type == "comment" and not $scope.reviewPanel.resolvedThreadIds[entry.thread_id]
|
|
|
+ entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length)
|
|
|
else if entry.type == "insert"
|
|
|
- entry.focused = (entry.offset <= cursor_offset <= entry.offset + entry.content.length)
|
|
|
+ entry.focused = (entry.offset <= selection_offset_start <= entry.offset + entry.content.length)
|
|
|
else if entry.type == "delete"
|
|
|
- entry.focused = (entry.offset == cursor_offset)
|
|
|
+ entry.focused = (entry.offset == selection_offset_start)
|
|
|
else if entry.type == "add-comment" and selection
|
|
|
entry.focused = true
|
|
|
|