diff --git a/src/editor/code/code-editor.controller.ts b/src/editor/code/code-editor.controller.ts index 5d4cc99a9d5b4f855d3a2eac16bf20f1dd4e35fb..081b4e3422022e2cd7afcd12bd9d423c82d4028d 100644 --- a/src/editor/code/code-editor.controller.ts +++ b/src/editor/code/code-editor.controller.ts @@ -177,7 +177,7 @@ export class CodeEditorController const linesAdded = linesInText.length - 1; // 前后换行 + 文本内换行 = 总新增行数 const lastLineOfInsert = insertLine + linesAdded - 1; // 排除末尾的换行符所在行 const lastLineContent = linesInText[linesInText.length - 2] || ''; // 取文本最后一行(排除末尾换行) - const newColumn = lastLineContent.length; + const newColumn = lastLineContent.length + 1; // Monaco 列号从1开始,末尾位置长度需要加1 // 更新光标位置并聚焦 const newPosition = new this.monaco!.Position(lastLineOfInsert, newColumn);