@@ -180,9 +180,7 @@ export class RenameInputField implements IContentWidget {
180
180
const bodyBox = getClientArea ( this . getDomNode ( ) . ownerDocument . body ) ;
181
181
const editorBox = getDomNodePagePosition ( this . _editor . getDomNode ( ) ) ;
182
182
183
- // FIXME@ulugbekna : can getVisibleRanges() be empty? if so what to do about it
184
- const firstLineInViewport = this . _editor . getVisibleRanges ( ) [ 0 ] . startLineNumber ;
185
- const cursorBoxTop = this . _editor . getTopForLineNumber ( this . _position ! . lineNumber ) - this . _editor . getTopForLineNumber ( firstLineInViewport ) ;
183
+ const cursorBoxTop = this . _getTopForPosition ( ) ;
186
184
187
185
this . _nPxAvailableAbove = cursorBoxTop + editorBox . top ;
188
186
this . _nPxAvailableBelow = bodyBox . height - this . _nPxAvailableAbove ;
@@ -391,6 +389,18 @@ export class RenameInputField implements IContentWidget {
391
389
this . _editor . layoutContentWidget ( this ) ;
392
390
}
393
391
392
+ private _getTopForPosition ( ) : number {
393
+ const visibleRanges = this . _editor . getVisibleRanges ( ) ;
394
+ let firstLineInViewport : number ;
395
+ if ( visibleRanges . length > 0 ) {
396
+ firstLineInViewport = visibleRanges [ 0 ] . startLineNumber ;
397
+ } else {
398
+ this . _logService . warn ( 'RenameInputField#_getTopForPosition: this should not happen - visibleRanges is empty' ) ;
399
+ firstLineInViewport = Math . max ( 1 , this . _position ! . lineNumber - 5 ) ; // @ulugbekna : fallback to current line minus 5
400
+ }
401
+ return this . _editor . getTopForLineNumber ( this . _position ! . lineNumber ) - this . _editor . getTopForLineNumber ( firstLineInViewport ) ;
402
+ }
403
+
394
404
private _trace ( ...args : any [ ] ) {
395
405
this . _logService . trace ( 'RenameInputField' , ...args ) ;
396
406
}
0 commit comments