Skip to content

Commit

Permalink
fix: #1359 empty line wrap count
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed May 9, 2023
1 parent f4caa00 commit 9b1f251
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ export function autoGrowTextArea(dom: HTMLTextAreaElement) {
measureDom.style.width = width + "px";
measureDom.innerText = dom.value.trim().length > 0 ? dom.value : "1";

const lineWrapCount = Math.max(0, dom.value.split("\n").length - 1);
const emptyLineWrap = Math.max(0, dom.value.split("\n\n").length - 1);
const height = parseFloat(window.getComputedStyle(measureDom).height);
const singleLineHeight = parseFloat(
window.getComputedStyle(singleLineDom).height,
);

const rows = Math.round(height / singleLineHeight) + lineWrapCount;
const rows = Math.round(height / singleLineHeight) + emptyLineWrap;

return rows;
}
Expand Down

0 comments on commit 9b1f251

Please sign in to comment.