Display carriage return

How can I display carriage return in the editor, if I have ‘\r’ in my content then I have to display cr in the editor, else I can code that my manipulating the Monaco dom but I need to get the dom node for a particular line, in which layer I can access getDomNodeForLine(),

currently, I’m hard coding like this but Its not working properly


    const configureEndOfLine = (editor: MonacoEditor) => {
        const createSpan = () => {
            let span = document.createElement('span');
            span.className = 'mtkw';
            span.innerText = 'cr';
            return span;
        }
        const appendCr = () => {
            let content = editor.getControl().getValue()
            let arr = content.split('\n')
            let lines = editor.node.getElementsByClassName('view-line');
            for (let i = 0; i < lines.length; i++) {
                let line = lines.item(i);
                let lineCon = arr[i];
                if (!lineCon.endsWith('\r')) continue;
                if (line.children[0].children.length > 0 && line.children[0].children[line.children[0].children.length - 1].innerHTML !== 'cr')
                    line.children[0].appendChild(createSpan());
            }
        }
        editor.onCursorPositionChanged(() => appendCr())
        editor.onDocumentContentChanged(() => appendCr())
        editor.onFocusChanged(() => appendCr())
        editor.onScrollChanged(() => appendCr())
    }

image

@Panneerselvam-D thank you for the discussion, I don’t believe the monaco-editor has an option at the moment to display line endings (there is actually a quite old bug in vscode about it as well Can't see Newlines when Render Control Characters is turned on · Issue #26646 · microsoft/vscode · GitHub) but there are solutions which have worked including this popular extension (https://open-vsx.org/extension/medo64/render-crlf).

If you can’t use the extension which supports the use-case and customizations you can likely inspire yourself from it as well.