File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,22 @@ module.exports = class DatatipManager {
257257 const component = this . editorView . getComponent ( ) ;
258258 // the screen position returned here is always capped to the max width of the text in this row
259259 const screenPosition = component . screenPositionForMouseEvent ( evt ) ;
260+ // the coordinates below represent X and Y positions on the screen of where the mouse event
261+ // occured and where the capped screenPosition is located
262+ const coordinates = {
263+ mouse : component . pixelPositionForMouseEvent ( evt ) ,
264+ screen : component . pixelPositionForScreenPosition ( screenPosition ) ,
265+ } ;
266+ const distance = Math . abs ( coordinates . mouse . left - coordinates . screen . left ) ;
267+
268+ // If the distance between the coordinates is greater than the default character width, it
269+ // means the mouse event occured quite far away from where the text ends on that row. Do not
270+ // show the datatip in such situations and hide any existing datatips (the mouse moved more to
271+ // the right, away from the actual text)
272+ if ( distance >= this . editor . getDefaultCharWidth ( ) ) {
273+ return this . hideDataTip ( ) ;
274+ }
275+
260276 const point = this . editor . bufferPositionForScreenPosition ( screenPosition ) ;
261277 if ( ( this . currentMarkerRange === null ) ||
262278 ( ! this . currentMarkerRange . containsPoint ( point ) ) ) {
You can’t perform that action at this time.
0 commit comments