Skip to content

默认 rime_mint.custom.yaml 中的 __include: code_limit:/patch 会导致 /+ 语法失效 #28

@WntFlm

Description

@WntFlm

问题描述

在默认的 rime_mint.custom.yaml 文件中,含有一个 __include 项,如果在之后追加带有 /+ 语法的值,原本应该追加(或者合并)的列表(或者字典)项会被整个覆盖。

问题示例

修改 rime_mint.custom.yaml 文件如下:

image

重新部署后 build/rime_mint.schema.yaml 文件中对应项如下:

image

注意其中 # 项值使用了 default.yaml 中、而非 rime_mint.schema.yaml 中的设定。这意味着 /+ 项只是覆盖了 rime_mint.schema.yaml 中对应项的值。

删除 __include 行后,重新部署,build/rime_mint.schema.yaml 文件中对应项如下:

image

此时字典正确合并。

可能原因

由于含有 __include 项,根据官方文档中的描述:

同一節點下,編譯指令的執行順序爲: __include: 包含指定節點 → 合併當前節點下的其他 key-value 數據 → __patch: 修改子節點。

这可能使得原本 /+ 项在 rime_mint.custom.yaml 内部提前展开,并在之后覆盖了 rime_mint.schema.yaml 中对应项的值。

可能的解决方法

将默认的 rime_mint.custom.yaml 文件中的 __include 值移至 rime_mint.schema.yaml

Activity

changed the title [-]默认 `rime_mint.custom.yaml` 中的 __include: code_limit:/patch 会导致`/+`语法失效[/-] [+]默认 `rime_mint.custom.yaml` 中的 `__include: code_limit:/patch` 会导致`/+`语法失效[/+] on Feb 25, 2024
changed the title [-]默认 `rime_mint.custom.yaml` 中的 `__include: code_limit:/patch` 会导致`/+`语法失效[/-] [+]默认 `rime_mint.custom.yaml` 中的 `__include: code_limit:/patch` 会导致 `/+` 语法失效[/+] on Feb 25, 2024
WntFlm

WntFlm commented on Feb 25, 2024

@WntFlm
Author

rime/librime#192
另一种可行的方法是使用 /+/+,这样 __include 只会展开第一个 /+,但是这样的写法本身就很奇怪,更像一个不得以而为之的方案,我觉得直接将 __include 项移出是一个更好的解决方法。

Mintimate

Mintimate commented on Feb 26, 2024

@Mintimate
Owner

测试了一下,确实__include/+的语法有冲突,直接导致/+的部分失效。感谢建议,用__include的场景不多,而且/+更方便,去除__include是个不错的方案。

added a commit that references this issue on Mar 2, 2024
90f6734
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

        Participants

        @WntFlm@Mintimate

        Issue actions

          默认 `rime_mint.custom.yaml` 中的 `__include: code_limit:/patch` 会导致 `/+` 语法失效 · Issue #28 · Mintimate/oh-my-rime