From 2d715583daca552a4017b678f2762bcd31363565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=80=80=E5=BF=B5=EF=BC=88=E4=BA=91?= =?UTF-8?q?=E8=B0=8C=EF=BC=89?= Date: Wed, 18 Dec 2024 20:10:57 +0800 Subject: [PATCH] fix: rendering error when line break appears at the beginning of text (#1871) --- .changeset/two-pumpkins-add.md | 5 +++++ packages/g-lite/src/services/TextService.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/two-pumpkins-add.md diff --git a/.changeset/two-pumpkins-add.md b/.changeset/two-pumpkins-add.md new file mode 100644 index 000000000..e46e708b4 --- /dev/null +++ b/.changeset/two-pumpkins-add.md @@ -0,0 +1,5 @@ +--- +'@antv/g-lite': patch +--- + +fix: rendering error when line break appears at the beginning of text diff --git a/packages/g-lite/src/services/TextService.ts b/packages/g-lite/src/services/TextService.ts index 52320f7de..bbc5dcd27 100644 --- a/packages/g-lite/src/services/TextService.ts +++ b/packages/g-lite/src/services/TextService.ts @@ -380,7 +380,7 @@ export class TextService { } // Backspace from line's end. - const currentLineLength = lines[lineIndex].length; + const currentLineLength = lines[lineIndex] ? lines[lineIndex].length : 0; let lastLineWidth = 0; let lastLineIndex = currentLineLength; for (let i = 0; i < currentLineLength; i++) {