Default line_width does not reflect the libyaml default of 80
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 lib/psych/visitors/yaml_tree.rb 中的節點樣式選擇處開始,將其對行寬的處理與 ext/psych/yaml/emitter.c 中描述的 libyaml 預設值進行比較。驗證在未明確指定 line_width 的情況下進行傾印,其行為是否與使用 line_width: 80 進行傾印相同,包括 folded-style 範例。
由索引模型根據 Issue 內容生成。
描述
This causes the folded style to not apply unless line_width: is passed explicitly:
> s = 'asjfal sf;lkasfj;aslkfaj slfkasfkajf a;slkfjaslkfaslkfj aslkfjaslkf asklfj askl fjaklsfj aslkfjaslfjaslkfjlkffjsa'
> Psych.dump(s, line_width: 80) == Psych.dump(s)
=> false
> puts Psych.dump(s, line_width: 80)
--- >-
asjfal sf;lkasfj;aslkfaj slfkasfkajf a;slkfjaslkfaslkfj aslkfjaslkf asklfj askl
fjaklsfj aslkfjaslfjaslkfjlkffjsa
> puts Psych.dump(s)
--- asjfal sf;lkasfj;aslkfaj slfkasfkajf a;slkfjaslkfaslkfj aslkfjaslkf asklfj askl
fjaklsfj aslkfjaslfjaslkfjlkffjsa
...
The libyaml default of 80 happens as follows:
First, the emitter best_width is set to 0 on initialization here:
memset(emitter, 0, sizeof(yaml_emitter_t));
It is then set to 80 in yaml_emitter_emit_stream_start here:
if (emitter->best_width >= 0
&& emitter->best_width <= emitter->best_indent*2) {
emitter->best_width = 80;
}
On the Ruby side, we pass the options including :line_width into the emitter, but the code that picks the node style does not account for the libyaml defaults:
elsif @line_width && o.length > @line_width
style = Nodes::Scalar::FOLDED
We should probably also default to 80 in yaml_tree.rb for uniform handling.
- 主要語言
- Ruby
- 星號
- 596
- 分支
- 228
- 平均合併
- 24 分鐘
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ruby/psych 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
Sexagesimal scalars are mis-scanned可能已有人在做 @ihamzatarar 於 13 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
Documentation
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
Psych.dump raises Encoding::CompatibilityError for UTF-16/UTF-32 strings可能已有人在做 @Halvanhelv 於 83 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 55/100
維護者通常 1 天內回覆
-
Psych::Emitter#start_document: tag-directive handles and prefixes are aliased as raw `char *`, and the Strings die inside the loop可能已有人在做 @ninjapanzer 於 14 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 68/100
維護者通常 1 天內回覆
相似的 Issue
-
🐛 bug 👩💻 équipe CE
難度 2/5 1-3 小時 新手友好度 68/100
betagouv/conseillers-entreprises#4835 ·
維護者通常 1 天內回覆
-
backlog enhancement github_actions priority: low risk: low
難度 2/5 1-3 小時 新手友好度 77/100
davidteren/mutineer#646 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
metanorma/isodoc#965 · 1 則留言 ·
維護者通常 1 天內回覆
-
verified
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 4 天內回覆