Skip to content

任意一侧内容以换行符结尾时,CodeDiff 错误折叠末尾内容 #173

Description

@automation2013

问题描述
使用 CodeDiff 进行文本对比时,只要 oldString 或 newString 任意一侧的内容以 \n 结尾,组件就会将末尾内容错误识别为空行并折叠,导致对比结果显示异常。
示例:
<CodeDiff old-string="line 1\nline 2\n" new-string="line 1\nline 2 changed" output-format="side-by-side" />
只要任意一侧末尾存在 \n,即可复现问题。
实际结果

  • 末尾内容被错误折叠
  • 最后一行无法正常展示
  • 对比区域内容显示不完整
    期望结果
    无论只有一侧还是两侧内容以 \n 结尾,都应正常显示完整对比内容。文件末尾换行符是合法文本内容,不应导致内容被折叠。
    环境
    v-code-diff: 1.16.0 Vue: 3.x output-format: side-by-side

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions