Skip to content

The position field stored in the cache of the first code block is incorrect #291

@bulletproof-system

Description

@bulletproof-system

I created a vault with only the Buttons(0.9.13) plugin, then created a file named buttons.md and wrote the following content


21321

name My Super Button
type command
action Toggle Pin

^button-super

name 日记
type command
action 日记: 打开/创建今天的日记
color default

^button-daily

button-daily

button-super

name Toggle Pin
type command
action Toggle pin

^button-example-command


'button-super' will be rendered as an Error loading button, and 'button-daily' and 'button-example-command' will render normally.

I debugged and found that the cache.blocks calculated in the addButtonToStore function is as follows, where the position field in the first block is incorrect(note position.start.line and position.end.line)

{
    "button-super": {
        "position": {
            "start": {
                "line": 7,
                "col": 0,
                "offset": 73
            },
            "end": {
                "line": 7,
                "col": 13,
                "offset": 86
            }
        },
        "id": "button-super",
        "path": "buttons.md",
        "swap": 0
    },
    "button-daily": {
        "position": {
            "start": {
                "line": 8,
                "col": 0,
                "offset": 87
            },
            "end": {
                "line": 13,
                "col": 3,
                "offset": 157
            }
        },
        "id": "button-daily",
        "path": "buttons.md",
        "swap": 0
    },
    "button-example-command": {
        "position": {
            "start": {
                "line": 21,
                "col": 0,
                "offset": 206
            },
            "end": {
                "line": 25,
                "col": 3,
                "offset": 266
            }
        },
        "id": "button-example-command",
        "path": "buttons.md",
        "swap": 0
    }
}

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