@@ -28,7 +28,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
28
28
import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
29
29
30
30
export const ctxCommentEditorFocused = new RawContextKey < boolean > ( 'commentEditorFocused' , false ) ;
31
- export const STARTING_EDITOR_HEIGHT = 5 * 18 ;
31
+ export const MIN_EDITOR_HEIGHT = 5 * 18 ;
32
32
export const MAX_EDITOR_HEIGHT = 25 * 18 ;
33
33
34
34
export interface LayoutableEditor {
@@ -122,11 +122,13 @@ export function calculateEditorHeight(parentEditor: LayoutableEditor, editor: IC
122
122
const lineHeight = editor . getOption ( EditorOption . lineHeight ) ;
123
123
const contentHeight = ( editor . getModel ( ) ?. getLineCount ( ) ! * lineHeight ) ?? editor . getContentHeight ( ) ; // Can't just call getContentHeight() because it returns an incorrect, large, value when the editor is first created.
124
124
if ( ( contentHeight > layoutInfo . height ) ||
125
- ( contentHeight < layoutInfo . height && currentHeight > STARTING_EDITOR_HEIGHT ) ) {
125
+ ( contentHeight < layoutInfo . height && currentHeight > MIN_EDITOR_HEIGHT ) ) {
126
126
const linesToAdd = Math . ceil ( ( contentHeight - layoutInfo . height ) / lineHeight ) ;
127
- const maxCommentEditorHeight = Math . max ( Math . min ( MAX_EDITOR_HEIGHT , parentEditor . getLayoutInfo ( ) . height - 90 ) , STARTING_EDITOR_HEIGHT ) ;
128
- const newEditorHeight = Math . min ( maxCommentEditorHeight , layoutInfo . height + ( lineHeight * linesToAdd ) ) ;
129
- return newEditorHeight ;
127
+ const lowerBoundOfMaxEditorHeight = Math . max ( parentEditor . getLayoutInfo ( ) . height - 90 , MIN_EDITOR_HEIGHT ) ;
128
+ const maxCommentEditorHeightForParentEditor = Math . min ( MAX_EDITOR_HEIGHT , lowerBoundOfMaxEditorHeight ) ;
129
+
130
+ const proposedHeight = layoutInfo . height + ( lineHeight * linesToAdd ) ;
131
+ return Math . min ( maxCommentEditorHeightForParentEditor , Math . max ( MIN_EDITOR_HEIGHT , proposedHeight ) ) ;
130
132
}
131
133
return currentHeight ;
132
134
}
0 commit comments