Skip to content

Performance issues with treesitter when there is entry with :PROPERTIES: #521

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

Closed
WhiteBlackGoose opened this issue Mar 5, 2023 · 9 comments
Labels
bug Something isn't working has-workaround This issue has a workaround

Comments

@WhiteBlackGoose
Copy link
Contributor

WhiteBlackGoose commented Mar 5, 2023

Describe the bug

Adding a new entry under first level header gets incredibly slow (up to 1s lag). E. g.

...
* Header
<caret>

In place of type *. It will lag for 500ms or so.

When I do it, it tries to redraw the whole thing on the first asterisk inserted. It does it wrong, because on the first asterisk it redraws everything into the color of the first level header. Especially noticeable when everything is expanded.

Steps to reproduce

  1. Open file
  2. Go to header "Blog"
  3. Type * (asterisk)
  4. It redraws the whole thing into pink and lags for a second

Expected behavior

Adding entries should be instant

Emacs functionality

No response

Minimal init.lua

Used the provided minimal_init.lua (no my configuration). link

Screenshots and recordings

No response

OS / Distro

NixOS

Neovim version/commit

0.9-dev 5c9bf0ea74aa9297227242f17058a9f0c4c0c115

Additional context

Thank you, this is an amazing plugin

@WhiteBlackGoose WhiteBlackGoose added the bug Something isn't working label Mar 5, 2023
@WhiteBlackGoose
Copy link
Contributor Author

And it throws a lot of errors when I try to use it without TS. Very frustrating :( (in my file, lags can be 2-3 seconds)

@WhiteBlackGoose
Copy link
Contributor Author

Workaround: insert space at the same time as asterisks

norm = { noremap = true, silent = true }
vim.api.nvim_set_keymap('n', 'c1', 'i*<space>', norm)
vim.api.nvim_set_keymap('n', 'c2', 'i**<space>', norm)
vim.api.nvim_set_keymap('n', 'c3', 'i***<space>', norm)
vim.api.nvim_set_keymap('n', 'c4', 'i****<space>', norm)

This works instantly. However, it's key that the space is inserted too. Otherwise, the same bug hits.

@jgollenz
Copy link
Contributor

jgollenz commented Mar 6, 2023

I can confirm this. This looks like a treesitter issue to me. I could narrow it down to

* foo
    SCHEDULED: <2023-03-09 Thu>
    :PROPERTIES:
    :END:
|
* bar
  :PROPERTIES:
  :END:

(pipe represents the cursor)

Inserting the * at this point should result in an error that is not detected in this case. I'll have to do some further investigation. Another workaround would be to not insert new headings manually but with <leader>oih from the previous heading (or its body).

edit: personally this never happened to me because when I hit Enter after * Blog|, nvim auto-indents and adds to white-spaces.

@jgollenz jgollenz added the has-workaround This issue has a workaround label Mar 6, 2023
@WhiteBlackGoose
Copy link
Contributor Author

The tree built by the treesitter also breaks often. I couldn't reproduce it yet, except when you type a few asterisks on a few line but not a space. But I feel like sometimes, headings without contents are interpreted compelteley wrong. E. g. folding in this text normally works as expected.

Expanded:

* Heading
** Another 1
** Another 2
** Another 3
** Another 4

Collapsed:

* Heading

Sometimes though the collapsed looks like this:

* Heading
** Another 3
** Another 4

@WhiteBlackGoose
Copy link
Contributor Author

WhiteBlackGoose commented Mar 9, 2023

folding breaks too

Here's a correct tree and incorrect folding

image

ts-bug

@rybaz
Copy link

rybaz commented Mar 9, 2023

Glad I'm not the only one having this issue. I have org files that previously worked fine not folding at all until I edit content underneath a heading, then it folds on itself.

@WhiteBlackGoose
Copy link
Contributor Author

@rybaz you can use my fork (#523), folding works perfectly there

@jgollenz
Copy link
Contributor

@WhiteBlackGoose @rybaz let's keep this issue on topic and move discussions about folding here

@kristijanhusak
Copy link
Member

Similar issue was reported here #625. It should be resolved on latest master + :TSUpdate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has-workaround This issue has a workaround
Projects
None yet
Development

No branches or pull requests

4 participants