@@ -3555,7 +3555,7 @@ def on_hover_description_async(view, point, hover_zone, popup_position) :
35553555
35563556 func_action = lambda x : view .run_command ("go_to_def" , args = {"point" : point }) if x == "go_to_def" else ""
35573557
3558- if html :
3558+ if html and not view . is_popup_visible () :
35593559 view .show_popup ("""
35603560 <html><head></head><body>
35613561 """ + js_css + """
@@ -3687,6 +3687,7 @@ def show_flow_errors(view) :
36873687
36883688 errors = []
36893689 description_by_row = {}
3690+ description_by_row_column = {}
36903691 regions = []
36913692 for deps in deps_list :
36923693 if deps .project_root is '/' :
@@ -3756,9 +3757,9 @@ def show_flow_errors(view) :
37563757 description += operation ["descr" ]
37573758
37583759 if not description :
3759- description += message ['descr' ]
3760+ description += "'" + message ['descr' ]+ "'"
37603761 else :
3761- description += ". " + message ['descr' ]
3762+ description += " " + message ['descr' ]
37623763
37633764 if row >= 0 :
37643765 row_description = description_by_row .get (row )
@@ -3769,6 +3770,8 @@ def show_flow_errors(view) :
37693770 }
37703771 if row_description and description not in row_description :
37713772 description_by_row [row ]["description" ] += '; ' + description
3773+
3774+ description_by_row_column [str (row )+ ":" + str (col )+ ":" + str (endcol )] = description
37723775
37733776 errors = result [1 ]['errors' ]
37743777
@@ -3777,7 +3780,7 @@ def show_flow_errors(view) :
37773780 'flow_error' , regions , 'scope.js' , 'dot' ,
37783781 sublime .DRAW_SQUIGGLY_UNDERLINE | sublime .DRAW_NO_FILL | sublime .DRAW_NO_OUTLINE
37793782 )
3780- return {"errors" : errors , "description_by_row" : description_by_row }
3783+ return {"errors" : errors , "description_by_row" : description_by_row , "description_by_row_column" : description_by_row_column }
37813784
37823785 view .erase_regions ('flow_error' )
37833786 view .set_status ('flow_error' , 'Flow: no errors' )
@@ -3893,11 +3896,13 @@ def on_modified_async_with_thread(self, recheck=True) :
38933896
38943897 self .errors = []
38953898 self .description_by_row = {}
3899+ self .description_by_row_column = {}
38963900 result = show_flow_errors (view )
38973901
38983902 if result :
38993903 self .errors = result ["errors" ]
39003904 self .description_by_row = result ["description_by_row" ]
3905+ self .description_by_row_column = result ["description_by_row_column" ]
39013906
39023907 sublime .set_timeout_async (lambda : self .on_selection_modified_async ())
39033908
@@ -3909,17 +3914,29 @@ def on_modified_async_with_thread(self, recheck=True) :
39093914
39103915 def on_hover (self , point , hover_zone ) :
39113916 view = self .view
3912- view .erase_phantoms ("flow_error" )
3913- if hover_zone != sublime .HOVER_GUTTER :
3917+ # view.erase_phantoms("flow_error")
3918+ if hover_zone != sublime .HOVER_TEXT :
39143919 return
39153920
39163921 sel = sublime .Region (point , point )
3922+
39173923 if (not view .match_selector (
39183924 sel .begin (),
39193925 'source.js'
39203926 ) and not view .find_by_selector ("source.js.embedded.html" )) or not self .errors or not view .get_regions ("flow_error" ):
39213927 hide_flow_errors (view )
39223928 return
3929+
3930+ is_hover_error = False
3931+ region_hover_error = None
3932+ for region in view .get_regions ("flow_error" ):
3933+ if region .contains (sel ):
3934+ region_hover_error = region
3935+ is_hover_error = True
3936+ break
3937+
3938+ if not is_hover_error :
3939+ return
39233940
39243941 settings = get_project_settings ()
39253942 if settings :
@@ -3940,12 +3957,13 @@ def on_hover(self, point, hover_zone) :
39403957 hide_flow_errors (view )
39413958 return
39423959
3943- row , col = view .rowcol (sel .begin ())
3960+ row_region , col_region = view .rowcol (region_hover_error .begin ())
3961+ row_region , endcol_region = view .rowcol (region_hover_error .end ())
39443962
3945- error_for_row = self .description_by_row . get ( row )
3963+ error = self .description_by_row_column [ str ( row_region ) + ":" + str ( col_region ) + ":" + str ( endcol_region )]
39463964
3947- if error_for_row :
3948- text = cgi .escape (error_for_row [ "description" ] ).split (" " )
3965+ if error :
3966+ text = cgi .escape (error ).split (" " )
39493967 html = ""
39503968 i = 0
39513969 while i < len (text ) - 1 :
@@ -3956,9 +3974,10 @@ def on_hover(self, point, hover_zone) :
39563974 if len (text ) % 2 != 0 :
39573975 html += text [len (text ) - 1 ]
39583976
3959- region_phantom = sublime . Region ( view .text_point ( row , error_for_row [ "col" ]), view . text_point ( row , error_for_row [ "col" ]) )
3960- sublime . set_timeout_async ( lambda : view . add_phantom ( "flow_error" , region_phantom , '<html style="padding: 0px; margin: 5px; background-color: rgba(255,255,255,0);"><body style="border-radius: 10px; padding: 10px; background-color: #F44336; margin: 0px;">' + html + '</body></html>' , sublime . LAYOUT_BELOW ))
3977+ row_region , col_region = view .rowcol ( region_hover_error . begin () )
3978+ row_region , endcol_region = view . rowcol ( region_hover_error . end ( ))
39613979
3980+ view .show_popup ('<html style="font-size: 0.75em; font-weight: bold; padding: 0px; margin: 0px; background-color: rgba(255,255,255,1);"><body style="padding: 5px; background-color: #F44336; margin: 0px;">' + html + '<br><a style="margin-top: 10px; display: block; color: #000;" href="copy_to_clipboard">Copy</a></body></html>' , sublime .COOPERATE_WITH_AUTO_COMPLETE | sublime .HIDE_ON_MOUSE_MOVE_AWAY , region_hover_error .begin (), 1150 , 80 , lambda action : sublime .set_clipboard (error ) or view .hide_popup () )
39623981
39633982 def on_selection_modified_async (self , * args ) :
39643983
0 commit comments