Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capturing content with headlines fails with virtual indent enabled #826

Closed
seflue opened this issue Nov 14, 2024 · 1 comment
Closed

Capturing content with headlines fails with virtual indent enabled #826

seflue opened this issue Nov 14, 2024 · 1 comment

Comments

@seflue
Copy link
Contributor

seflue commented Nov 14, 2024

When capturing content, which contains a headline, the following error could occur.

Error executing vim.schedule lua callback: ...tributions/orgmode/lua/orgmode/utils/treesitter/init.lua:153: Invalid buffer id: -1
stack traceback:
        [C]: in function 'nvim_buf_get_changedtick'
        ...tributions/orgmode/lua/orgmode/utils/treesitter/init.lua:153: in function 'get_matches'
        ...ts/nvim/contributions/orgmode/lua/orgmode/org/indent.lua:251: in function 'indentexpr'
        ...vim/contributions/orgmode/lua/orgmode/files/headline.lua:138: in function 'modifier'
        ...vim/contributions/orgmode/lua/orgmode/files/headline.lua:1031: in function '_adapt_headline_level'
        .../nvim/contributions/orgmode/lua/orgmode/capture/init.lua:177: in function '_refile_from_capture_buffer'
        .../nvim/contributions/orgmode/lua/orgmode/capture/init.lua:113: in function ''
        vim/_editor.lua: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I took a look at the code and found out, that an invalid buffer is not handled properly in the virtual indent code. While refiling captured content, it can acctually happen, that the buffer is already invalid, when the code runs.

I created a PR #825.

@kristijanhusak: I also find, that the refiling code is quite long and a lot can happen, which let's refiling fail and the user is faced with a stack trace. I played around with some refactoring and more fine granular error handling. Would you appreciate such a refactoring or should we keep it as it is?

@kristijanhusak
Copy link
Member

Closing since PR fixed the issue.

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

No branches or pull requests

2 participants