Skip to content

Commit cd514b5

Browse files
authored
Fix min comment editor height (microsoft#194465)
Fixes microsoft#194429
1 parent ba36ae4 commit cd514b5

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/vs/workbench/contrib/comments/browser/commentNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language';
1616
import { MarkdownRenderer } from 'vs/editor/contrib/markdownRenderer/browser/markdownRenderer';
1717
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1818
import { ICommentService } from 'vs/workbench/contrib/comments/browser/commentService';
19-
import { LayoutableEditor, STARTING_EDITOR_HEIGHT, SimpleCommentEditor, calculateEditorHeight } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor';
19+
import { LayoutableEditor, MIN_EDITOR_HEIGHT, SimpleCommentEditor, calculateEditorHeight } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor';
2020
import { Selection } from 'vs/editor/common/core/selection';
2121
import { Emitter, Event } from 'vs/base/common/event';
2222
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -72,7 +72,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
7272
private _commentEditor: SimpleCommentEditor | null = null;
7373
private _commentEditorDisposables: IDisposable[] = [];
7474
private _commentEditorModel: ITextModel | null = null;
75-
private _editorHeight = STARTING_EDITOR_HEIGHT;
75+
private _editorHeight = MIN_EDITOR_HEIGHT;
7676

7777
private _isPendingLabel!: HTMLElement;
7878
private _timestamp: HTMLElement | undefined;

src/vs/workbench/contrib/comments/browser/commentReply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ICommentService } from 'vs/workbench/contrib/comments/browser/commentSe
2828
import { CommentContextKeys } from 'vs/workbench/contrib/comments/common/commentContextKeys';
2929
import { ICommentThreadWidget } from 'vs/workbench/contrib/comments/common/commentThreadWidget';
3030
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
31-
import { LayoutableEditor, STARTING_EDITOR_HEIGHT, SimpleCommentEditor, calculateEditorHeight } from './simpleCommentEditor';
31+
import { LayoutableEditor, MIN_EDITOR_HEIGHT, SimpleCommentEditor, calculateEditorHeight } from './simpleCommentEditor';
3232

3333
const COMMENT_SCHEME = 'comment';
3434
let INMEM_MODEL_ID = 0;
@@ -45,7 +45,7 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
4545
private _commentFormActions!: CommentFormActions;
4646
private _commentEditorActions!: CommentFormActions;
4747
private _reviewThreadReplyButton!: HTMLElement;
48-
private _editorHeight = STARTING_EDITOR_HEIGHT;
48+
private _editorHeight = MIN_EDITOR_HEIGHT;
4949

5050
constructor(
5151
readonly owner: string,

src/vs/workbench/contrib/comments/browser/simpleCommentEditor.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2828
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
2929

3030
export const ctxCommentEditorFocused = new RawContextKey<boolean>('commentEditorFocused', false);
31-
export const STARTING_EDITOR_HEIGHT = 5 * 18;
31+
export const MIN_EDITOR_HEIGHT = 5 * 18;
3232
export const MAX_EDITOR_HEIGHT = 25 * 18;
3333

3434
export interface LayoutableEditor {
@@ -122,11 +122,13 @@ export function calculateEditorHeight(parentEditor: LayoutableEditor, editor: IC
122122
const lineHeight = editor.getOption(EditorOption.lineHeight);
123123
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.
124124
if ((contentHeight > layoutInfo.height) ||
125-
(contentHeight < layoutInfo.height && currentHeight > STARTING_EDITOR_HEIGHT)) {
125+
(contentHeight < layoutInfo.height && currentHeight > MIN_EDITOR_HEIGHT)) {
126126
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));
130132
}
131133
return currentHeight;
132134
}

0 commit comments

Comments
 (0)