@@ -243,76 +243,74 @@ export class SignatureHelpManager {
243243 ) ,
244244 element
245245 )
246- this . signatureHelpDisposables = this . mountSignatureHelp ( editor , position , element )
246+ this . signatureHelpDisposables = mountSignatureHelp ( editor , position , element )
247247 }
248248 } catch ( err ) {
249249 console . error ( err )
250250 }
251251 }
252252
253- /**
254- * Mounts displays a signature help view component at a specific position in a given Atom Text editor
255- *
256- * @param editor The Atom Text editor instance to host the data tip view
257- * @param position The position on which to show the signature help view
258- * @param view The signature help component to display
259- * @returns A composite object to release references at a later stage
260- */
261- mountSignatureHelp ( editor : TextEditor , position : Point , element : HTMLElement ) {
262- const disposables = new CompositeDisposable ( )
263- const overlayMarker = editor . markBufferRange ( new Range ( position , position ) , {
264- invalidate : "overlap" , // TODO It was never. Shouldn't be surround?
265- } )
266-
267- makeOverlaySelectable ( editor , element )
268-
269- const marker = editor . decorateMarker ( overlayMarker , {
270- type : "overlay" ,
271- class : "signature-overlay" ,
272- position : "head" , // follows the cursor
273- item : element ,
274- } )
253+ /** Unmounts / hides the most recent data tip view component */
254+ unmountDataTip ( ) {
255+ this . signatureHelpDisposables . dispose ( )
256+ }
257+ }
275258
276- // TODO do this for some valid range
277- // editor.onDidChangeCursorPosition(
278- // () => marker.destroy() // destroy the marker if user clicks somewhere else
279- // )
280-
281- // move box above the current editing line
282- // HACK: patch the decoration's style so it is shown above the current line
283- setTimeout ( ( ) => {
284- const overlay = element . parentElement
285- if ( ! overlay ) {
286- return
287- }
288- const hight = element . getBoundingClientRect ( ) . height
289- const lineHight = editor . getLineHeightInPixels ( )
290- //@ts -ignore internal type
291- const availableHight = ( position . row - editor . getFirstVisibleScreenRow ( ) ) * lineHight
292- if ( hight < availableHight + 80 ) {
293- overlay . style . transform = `translateY(-${ lineHight + hight } px)`
259+ /**
260+ * Mounts displays a signature help view component at a specific position in a given Atom Text editor
261+ *
262+ * @param editor The Atom Text editor instance to host the data tip view
263+ * @param position The position on which to show the signature help view
264+ * @param view The signature help component to display
265+ * @returns A composite object to release references at a later stage
266+ */
267+ function mountSignatureHelp ( editor : TextEditor , position : Point , element : HTMLElement ) {
268+ const disposables = new CompositeDisposable ( )
269+ const overlayMarker = editor . markBufferRange ( new Range ( position , position ) , {
270+ invalidate : "overlap" , // TODO It was never. Shouldn't be surround?
271+ } )
272+
273+ makeOverlaySelectable ( editor , element )
274+
275+ const marker = editor . decorateMarker ( overlayMarker , {
276+ type : "overlay" ,
277+ class : "signature-overlay" ,
278+ position : "head" , // follows the cursor
279+ item : element ,
280+ } )
281+
282+ // TODO do this for some valid range
283+ // editor.onDidChangeCursorPosition(
284+ // () => marker.destroy() // destroy the marker if user clicks somewhere else
285+ // )
286+
287+ // move box above the current editing line
288+ // HACK: patch the decoration's style so it is shown above the current line
289+ setTimeout ( ( ) => {
290+ const overlay = element . parentElement
291+ if ( ! overlay ) {
292+ return
293+ }
294+ const hight = element . getBoundingClientRect ( ) . height
295+ const lineHight = editor . getLineHeightInPixels ( )
296+ //@ts -ignore internal type
297+ const availableHight = ( position . row - editor . getFirstVisibleScreenRow ( ) ) * lineHight
298+ if ( hight < availableHight + 80 ) {
299+ overlay . style . transform = `translateY(-${ lineHight + hight } px)`
300+ } else {
301+ // move right so it does not overlap with auto-complete-list
302+ // @ts -ignore
303+ const autoCompleteList = ( editor . getElement ( ) as TextEditorElement ) . querySelector ( "autocomplete-suggestion-list" )
304+ if ( autoCompleteList ) {
305+ overlay . style . transform = `translateX(${ autoCompleteList . clientWidth } px)`
294306 } else {
295- // move right so it does not overlap with auto-complete-list
296- // @ts -ignore
297- const autoCompleteList = ( editor . getElement ( ) as TextEditorElement ) . querySelector (
298- "autocomplete-suggestion-list"
299- )
300- if ( autoCompleteList ) {
301- overlay . style . transform = `translateX(${ autoCompleteList . clientWidth } px)`
302- } else {
303- overlay . style . transform = "translateX(300px)"
304- }
307+ overlay . style . transform = "translateX(300px)"
305308 }
306- element . style . visibility = "visible"
307- } , 100 )
308-
309- disposables . add ( new Disposable ( ( ) => overlayMarker . destroy ( ) ) , new Disposable ( ( ) => marker . destroy ( ) ) )
309+ }
310+ element . style . visibility = "visible"
311+ } , 100 )
310312
311- return disposables
312- }
313+ disposables . add ( new Disposable ( ( ) => overlayMarker . destroy ( ) ) , new Disposable ( ( ) => marker . destroy ( ) ) )
313314
314- /** Unmounts / hides the most recent data tip view component */
315- unmountDataTip ( ) {
316- this . signatureHelpDisposables . dispose ( )
317- }
315+ return disposables
318316}
0 commit comments