@@ -96,13 +96,7 @@ module.exports = class DatatipManager {
9696 editor . onDidDestroy ( ( ) => disposable . dispose ( ) ) ;
9797 } ) ,
9898 atom . commands . add ( 'atom-text-editor' , {
99- 'datatip:toggle' : ( evt ) => {
100- const editor = evt . currentTarget . getModel ( ) ;
101- if ( atom . workspace . isTextEditor ( editor ) ) {
102- const position = evt . currentTarget . getModel ( ) . getCursorBufferPosition ( ) ;
103- this . showDataTip ( editor , position , undefined ) ;
104- }
105- }
99+ 'datatip:toggle' : ( evt ) => this . onCommandEvt ( evt )
106100 } ) ,
107101 atom . config . observe ( 'atom-ide-datatip.showDataTipOnCursorMove' , toggleSwitch => {
108102 this . showDataTipOnCursorMove = toggleSwitch ;
@@ -281,6 +275,25 @@ module.exports = class DatatipManager {
281275 } , 500 , evt ) ;
282276 }
283277
278+ /**
279+ * the central command event handler
280+ * @param { CommandEvent } evt command event
281+ */
282+ onCommandEvt ( evt ) {
283+ const editor = evt . currentTarget . getModel ( ) ;
284+
285+ if ( atom . workspace . isTextEditor ( editor ) ) {
286+ const position = evt . currentTarget . getModel ( ) . getCursorBufferPosition ( ) ;
287+
288+ const isTooltipOpenForPosition = this . currentMarkerRange && this . currentMarkerRange . containsPoint ( position ) ;
289+ if ( isTooltipOpenForPosition ) {
290+ return this . unmountDataTip ( ) ;
291+ }
292+
293+ this . showDataTip ( editor , position , undefined ) ;
294+ }
295+ }
296+
284297 /**
285298 * evaluates the responsible DatatipProvider to call for data tip information at a given position in a specific Atom Text editor
286299 * @param {TextEditor } editor the Atom Text editor instance to be used
0 commit comments