{"record":{"id":"80c477ab5a25a054","repo":"ajaxorg/ace","slug":"use-of-document-insertnewline-is-deprecated-use-i","errorCode":null,"errorMessage":"Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.","messagePattern":"Use of document\\.insertNewLine is deprecated\\. Use insertMergedLines\\(position, \\['', ''\\]\\) instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/document.js","lineNumber":224,"sourceCode":"     * @param firstRow\n     * @param lastRow\n     * @returns {String[]}\n     \n     * @deprecated\n     */\n    removeLines(firstRow, lastRow) {\n        console.warn(\"Use of document.removeLines is deprecated. Use the removeFullLines method instead.\");\n        return this.removeFullLines(firstRow, lastRow);\n    }\n\n    /**\n     * @param position\n     * @returns {Point}\n     \n     * @deprecated\n     */\n    insertNewLine(position) {\n        console.warn(\"Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.\");\n        return this.insertMergedLines(position, [\"\", \"\"]);\n    }\n\n    /**\n     * Inserts a block of `text` at the indicated `position`.\n     * @param {Point} position The position to start inserting at; it's an object that looks like `{ row: row, column: column}`\n     * @param {String} text A chunk of text to insert\n     * @returns {Point} The position ({row, column}) of the last line of `text`. If the length of `text` is 0, this function simply returns `position`. \n     \n     **/\n    insert(position, text) {\n        // Only detect new lines if the document has no line break yet.\n        if (this.getLength() <= 1)\n            this.$detectNewLine(text);\n        \n        return this.insertMergedLines(position, this.$split(text));\n    }\n    ","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/ajaxorg/ace/blob/2c1eddc392eb92cf222a4478f1893d2b2c354fb0/src/document.js#L206-L242","documentation":"A deprecation warning printed by Document.insertNewLine. Inserting a newline is now expressed uniformly as insertMergedLines with an empty string before and after the break; the old method delegates to exactly that.","triggerScenarios":"Calling session.doc.insertNewLine(position) in legacy code that adds line breaks directly on the document.","commonSituations":"Old macros/plugins that build documents line by line; code copied from pre-rename Ace examples.","solutions":["Replace doc.insertNewLine(pos) with doc.insertMergedLines(pos, ['', ''])","Consider doc.insert(pos, '\\n') if you prefer plain text insertion","Grep for 'insertNewLine(' and migrate all call sites","The warning is harmless; behavior is a direct delegation"],"exampleFix":"// before\ndoc.insertNewLine({row: 2, column: 0});\n// after\ndoc.insertMergedLines({row: 2, column: 0}, ['', '']);","handlingStrategy":"validation","validationCode":"if (typeof doc.insertMergedLines !== 'function') throw new Error('insertMergedLines unavailable; upgrade ace');\ndoc.insertMergedLines(pos, ['', '']);","typeGuard":"function hasMergedLines(doc) { return doc && typeof doc.insertMergedLines === 'function'; }","tryCatchPattern":"try {\n  doc.insertMergedLines(pos, ['', '']);\n} catch (e) {\n  console.error('newline insert failed', e);\n}","preventionTips":["Replace insertNewLine with insertMergedLines(pos, ['', '']) or doc.insert(pos, '\\n')","Suppress legacy method usage via lint rules forbidding the old names","Test against a pinned ace version where you've verified the modern API"],"tags":["deprecation","document-api","console-warning"],"backgroundTag":"deprecated-api-migration","analyzedSha":"2c1eddc392eb92cf222a4478f1893d2b2c354fb0","analyzedAt":"2026-08-30T00:39:52.222Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}