From 90763048bcdd0edd36b2a188c76ad3642cd10040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hatcher?= Date: Mon, 3 Mar 2025 19:44:23 +0100 Subject: [PATCH] FIX: Wrap text properly This fixes a bug where if you were wrapping text, the first word was repeated. We really need tests! --- .../IronCalc/src/components/WorksheetCanvas/worksheetCanvas.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/IronCalc/src/components/WorksheetCanvas/worksheetCanvas.ts b/webapp/IronCalc/src/components/WorksheetCanvas/worksheetCanvas.ts index 19a40d5..5a4ea4b 100644 --- a/webapp/IronCalc/src/components/WorksheetCanvas/worksheetCanvas.ts +++ b/webapp/IronCalc/src/components/WorksheetCanvas/worksheetCanvas.ts @@ -101,7 +101,8 @@ function computeWrappedLines( for (const line of rawLines) { const words = line.split(" "); let currentLine = words[0]; - for (const word of words) { + for (let i = 1; i < words.length; i += 1) { + const word = words[i]; const testLine = `${currentLine} ${word}`; const textWidth = context.measureText(testLine).width; if (textWidth < width) {