@@ -79,20 +79,28 @@ export class CMJumpToDefinition extends CodeMirrorIntegration {
7979 virtualEditor : CodeMirrorVirtualEditor ,
8080 event : MouseEvent
8181 ) {
82- document . body . addEventListener (
83- 'mouseup' ,
84- ( mouseUpEvent : MouseEvent ) => {
85- if ( mouseUpEvent . target !== event . target ) {
86- // Cursor moved, e.g. block selection was attempted, see:
87- // https://github.com/jupyter-lsp/jupyterlab-lsp/issues/823
88- return ;
82+ // For Alt + click we need to wait for mouse up to enable users to create
83+ // rectangular selections with Alt + drag.
84+ if ( this . modifierKey === 'Alt' ) {
85+ document . body . addEventListener (
86+ 'mouseup' ,
87+ ( mouseUpEvent : MouseEvent ) => {
88+ if ( mouseUpEvent . target !== event . target ) {
89+ // Cursor moved, possibly block selection was attempted, see:
90+ // https://github.com/jupyter-lsp/jupyterlab-lsp/issues/823
91+ return ;
92+ }
93+ return this . _jumpToDefinitionOrRefernce ( virtualEditor , event ) ;
94+ } ,
95+ {
96+ once : true
8997 }
90- return this . _jumpToDefinitionOrRefernce ( virtualEditor , event ) ;
91- } ,
92- {
93- once : true
94- }
95- ) ;
98+ ) ;
99+ } else {
100+ // For Ctrl + click we need to act on mouse down to prevent
101+ // adding multiple cursors if jump were to occur.
102+ return this . _jumpToDefinitionOrRefernce ( virtualEditor , event ) ;
103+ }
96104 }
97105
98106 private _jumpToDefinitionOrRefernce (
0 commit comments