Skip to content

增强空格处理功能:删除中文标点后空格,处理连续多空格#59

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-8b066aeb-9cf2-40b1-a692-efa57944654a
Draft

增强空格处理功能:删除中文标点后空格,处理连续多空格#59
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-8b066aeb-9cf2-40b1-a692-efa57944654a

Conversation

Copy link

Copilot AI commented Sep 25, 2025

功能概述

添加了增强的空格处理功能,解决从网页复制文本时常见的空格问题。新功能通过 g:pangu_rule_spacing_enhancement 配置项控制,默认关闭以保持向后兼容性。

解决的问题

  1. 中文标点符号后的多余空格 - 网页复制文本时经常出现的问题
  2. 行内连续多个空格 - 处理明显的多余空格(4个或以上)
  3. 保留行首空格 - 正确的缩进不受影响
  4. 行尾空格 - 由现有的 g:pangu_rule_trailing_whitespace 处理

使用示例

# 启用增强空格处理
let g:pangu_rule_spacing_enhancement = 1

# 处理效果:
- 从网页复制的文本。 经常有多余空格
+ 从网页复制的文本。经常有多余空格

- 标点符号,   多个空格问题
+ 标点符号,多个空格问题

- 这里有    四个空格问题
+ 这里有 四个空格问题

# 缩进保留:
    正确的缩进应该保留 ✓
        更深的缩进也要保留 ✓

实现特点

  • 保守处理:只处理明显的多余空格(4个以上),避免影响现有的中英文间距规则
  • 向后兼容:默认关闭,现有用户不受影响
  • 精确匹配:只处理中文标点符号后的空格,不影响英文标点
  • 保留缩进:行首空格完全保留,维持代码和文档的格式

配置方式

" 启用增强空格处理
let g:pangu_rule_spacing_enhancement = 1

" 配合现有规则使用
let g:pangu_rule_trailing_whitespace = 1  " 处理行尾空格

测试覆盖

添加了完整的测试用例,验证:

  • 中文标点符号后空格删除
  • 连续多空格处理
  • 缩进保留
  • 与现有功能的兼容性

Fixes #issue_number

Original prompt

This section details on the original issue you should resolve

<issue_title>建议增强对空格的处理</issue_title>
<issue_description>1. 中文标点符号之后的空格(1个或多个),通常这是多余的,在网页上复制文本时,经常会遇到这种情形,需要删除。
2. 若连续多个空格在行内,通常这是错误的,需要处理,但具体是仅保留一个还是全部删除,还挺复杂,简单处理的话,就是仅保留一个空格。
3. 若空格(1个或多个)在行首,通常这是正确的,无须处理。
4. 若空格(1个或多个)在行尾,这已经有无数的 vim 插件在处理,可选。</issue_description>

Comments on the Issue (you are @copilot in this section)

@hotoo @VimWei 非常好的建议。请问你有没有兴趣贡献代码?
Fixes #58

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 25, 2025 14:44
Co-authored-by: hotoo <143572+hotoo@users.noreply.github.com>
Co-authored-by: hotoo <143572+hotoo@users.noreply.github.com>
Copilot AI changed the title [WIP] 建议增强对空格的处理 增强空格处理功能:删除中文标点后空格,处理连续多空格 Sep 25, 2025
Copilot AI requested a review from hotoo September 25, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

建议增强对空格的处理

2 participants