Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: the error clip the last char when linebreak (#1745)

Ran Luo009b5b4708a9
diff --git a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
index 8d52456fc4..6b6fdd1cb1 100644
--- a/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
+++ b/packages/engine-render/src/components/docs/layout/block/paragraph/layout-ruler.ts
@@ -129,6 +129,10 @@ function _divideOperator(
const sliceGlyphGroupWidth = __getGlyphGroupWidth(sliceGlyphGroup);
if (sliceGlyphGroupWidth > divide.width) {
+ // To avoid infinity loop when width is less than one char's width.
+ if (sliceGlyphGroup.length > 1) {
+ glyphGroup.unshift(sliceGlyphGroup.pop()!);
+ }
break;
}
}