Blank line preservation
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, typescript
- 领域
- tooling
调研方向
未指定任何文件、测试或入口点;首先定位节点字符串化和代码移动 API。定义并测试 spaceBefore 和 spaceAfter 如何表示空行、注释、行首换行符和缩进,并确定 toString(true) 是否包含它们。
由索引模型根据 Issue 内容生成。
描述
When moving a block of code, you can use toString on each node and "paste" the result by using the appropriate method. There needs to be a way to preserve blank lines between nodes, so we can preserve the author's style.
The first idea that comes to mind is a method that returns a string containing only newlines (and maybe indentation?) corresponding to the number of blank lines before or after the node (so two variants). This string can then be "pasted" just like the toString result.
As an example:
foo()
// comment 1
bar()
// comment 2
foo()
Assume the bar() expression is represented by node:
node.spaceBefore() // => "\n\n// comment 1\n"
node.toString() // => "bar()"
node.spaceAfter() // => "\n\n\n// comment 2\n"
In the above example, the \n that begins bar()'s line is included in the spaceBefore result. And the \n that begins the line after that is included in the spaceAfter result. I'm not certain, but I think that's the expected behavior.
I'm also undecided if indentation should be included or not. I'm leaning towards no, because toString currently strips indentation and we should match that behavior.
Another thing: maybe toString(true) can include the result of spaceAfter (and even the result of spaceBefore if we're the first sibling of a BlockStatement) to make things easier?
These decisions could easily be a source of many bugs if we aren't careful.
- 主要语言
- TypeScript
- 星标
- 16
- 派生
- 1
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
alloc/nebu 的其他 Issue
-
enhancement
难度 4/5 3-5 天 新手友好度 35/100
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
-
enhancement
难度 3/5 1-2 天 新手友好度 35/100
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
aws/agentcore-cli#2606 ·
维护者通常 1 天内回复
-
ai-driven-qa bug Cosmetic
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
ai-driven-qa bug claude Minor
难度 2/5 1-3 小时 新手友好度 64/100
linagora/twake-mail-admin#301 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
reproduced
难度 2/5 1-3 小时 新手友好度 70/100
anomalyco/opencode#56038 · 1 条评论 ·
维护者通常 1 天内回复