@@ -31,7 +31,7 @@ import { registerThemingParticipant } from 'vs/platform/theme/common/themeServic
31
31
import { STATUS_BAR_ITEM_ACTIVE_BACKGROUND , STATUS_BAR_ITEM_HOVER_BACKGROUND } from 'vs/workbench/common/theme' ;
32
32
import { CommentGlyphWidget , overviewRulerCommentingRangeForeground } from 'vs/workbench/contrib/comments/browser/commentGlyphWidget' ;
33
33
import { ICommentInfo , ICommentService } from 'vs/workbench/contrib/comments/browser/commentService' ;
34
- import { isMouseUpEventMatchMouseDown , parseMouseDownInfoFromEvent , ReviewZoneWidget } from 'vs/workbench/contrib/comments/browser/commentThreadZoneWidget' ;
34
+ import { isMouseUpEventDragFromMouseDown , parseMouseDownInfoFromEvent , ReviewZoneWidget } from 'vs/workbench/contrib/comments/browser/commentThreadZoneWidget' ;
35
35
import { ctxCommentEditorFocused , SimpleCommentEditor } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor' ;
36
36
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
37
37
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget' ;
@@ -405,7 +405,12 @@ export class CommentController implements IEditorContribution {
405
405
}
406
406
407
407
private onEditorMouseMove ( e : IEditorMouseEvent ) : void {
408
- this . _commentingRangeDecorator . updateHover ( e . target . position ?. lineNumber ) ;
408
+ const position = e . target . position ?. lineNumber ;
409
+ if ( e . event . leftButton . valueOf ( ) && position && this . mouseDownInfo ) {
410
+ this . _commentingRangeDecorator . updateSelection ( position , new Range ( this . mouseDownInfo . lineNumber , 1 , position , 1 ) ) ;
411
+ } else {
412
+ this . _commentingRangeDecorator . updateHover ( position ) ;
413
+ }
409
414
}
410
415
411
416
private onEditorChangeCursorSelection ( e ?: ICursorSelectionChangedEvent ) : void {
@@ -691,22 +696,37 @@ export class CommentController implements IEditorContribution {
691
696
}
692
697
693
698
private onEditorMouseUp ( e : IEditorMouseEvent ) : void {
694
- const matchedLineNumber = isMouseUpEventMatchMouseDown ( this . mouseDownInfo , e ) ;
699
+ const matchedLineNumber = isMouseUpEventDragFromMouseDown ( this . mouseDownInfo , e ) ;
695
700
this . mouseDownInfo = null ;
696
701
697
702
if ( matchedLineNumber === null || ! e . target . element ) {
698
703
return ;
699
704
}
700
-
701
- if ( e . target . element . className . indexOf ( 'comment-diff-added' ) >= 0 ) {
702
- const lineNumber = e . target . position ! . lineNumber ;
703
- // Check for selection at line number.
704
- let range : Range = new Range ( lineNumber , 1 , lineNumber , 1 ) ;
705
- const selection = this . editor . getSelection ( ) ;
706
- if ( selection && ( selection . startLineNumber <= lineNumber ) && ( lineNumber <= selection . endLineNumber ) ) {
707
- range = selection ;
708
- this . editor . setSelection ( new Range ( selection . endLineNumber , 1 , selection . endLineNumber , 1 ) ) ;
705
+ const mouseUpIsOnDecorator = ( e . target . element . className . indexOf ( 'comment-diff-added' ) >= 0 ) ;
706
+
707
+ const lineNumber = e . target . position ! . lineNumber ;
708
+ let range : Range | undefined ;
709
+ let selection : Range | null | undefined ;
710
+ // Check for drag along gutter decoration
711
+ if ( ( matchedLineNumber !== lineNumber ) ) {
712
+ if ( matchedLineNumber > lineNumber ) {
713
+ selection = new Range ( matchedLineNumber , this . editor . getModel ( ) ! . getLineLength ( matchedLineNumber ) + 1 , lineNumber , 1 ) ;
714
+ } else {
715
+ selection = new Range ( matchedLineNumber , 1 , lineNumber , this . editor . getModel ( ) ! . getLineLength ( lineNumber ) + 1 ) ;
709
716
}
717
+ } else if ( mouseUpIsOnDecorator ) {
718
+ selection = this . editor . getSelection ( ) ;
719
+ }
720
+
721
+ // Check for selection at line number.
722
+ if ( selection && ( selection . startLineNumber <= lineNumber ) && ( lineNumber <= selection . endLineNumber ) ) {
723
+ range = selection ;
724
+ this . editor . setSelection ( new Range ( selection . endLineNumber , 1 , selection . endLineNumber , 1 ) ) ;
725
+ } else if ( mouseUpIsOnDecorator ) {
726
+ range = new Range ( lineNumber , 1 , lineNumber , 1 ) ;
727
+ }
728
+
729
+ if ( range ) {
710
730
this . addOrToggleCommentAtLine ( range , e ) ;
711
731
}
712
732
}
0 commit comments