Skip to content

@jsvision/code-editor / clipCodeEditorDisplayText

Function: clipCodeEditorDisplayText()

clipCodeEditorDisplayText(text, maximumWidth, ellipsis?): string

Defined in: code-editor/src/i18n/presentation.ts:47

Clips text to terminal display cells without splitting a wide code point.

Combining marks are retained only when their preceding base glyph fits. When clipping is needed, the default ellipsis consumes one cell and makes the truncation visible.

Parameters

text

string

Inert terminal text to clip.

maximumWidth

number

Available terminal cells.

ellipsis?

boolean = true

Whether to reserve a final cell for an ellipsis when text is truncated.

Returns

string

A display-cell-bounded prefix.

Example

ts
clipCodeEditorDisplayText('A界B', 3); // 'A界'