nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.03k stars 134 forks source link

org-next-visible-heading goes to invisible headings #774

Closed SlayerOfTheBad closed 3 months ago

SlayerOfTheBad commented 3 months ago

Describe the bug

When org-next-visible-heading (OrgMappings:next_visible_heading()) is called, the cursor is moved to the next heading, regardless of whether it is visible or not.

Steps to reproduce

Assume a file

* Heading 1
** Heading 1.1
*** Heading 1.1.1
    Loremus Ipsumus
*** Heading 1.1.2
    Some other fake text
** Heading 1.2
   Heading 1.2 contains some other text
** Heading 1.3
*** Heading 1.3.1
    There's a link to [[https://google.com][Google]] in here.
*** Heading 1.3.2
    And here's a link to [[https://gitlab.com][Gitlab]]!

Collapse this to show as

* Heading 1
** Heading 1.1 ...
** Heading 1.2 ...
** Heading 1.3 ...
  1. Go to the first line. (vim.cmd([[norm gg]]))
  2. Invoke OrgMappings:next_visible_heading twice. (vim.cmd([[norm }}]]))

Actual behaviour: Cursor is present at ** Heading 1.1 (Internally at *** Heading 1.1.1)

Expected behavior

Have cursor present at ** Heading 1.2.

Emacs functionality

Exists in Emacs Orgmode - Moves to ** Heading 1.2

Minimal init.lua

Not relevant for reproducing the bug.

Screenshots and recordings

cut-nvim.webm cut-emacs.webm

OS / Distro

Arch Linux & Ubuntu 24.04

Neovim version/commit

NVIM v0.10.1 & NVIM v0.10.1-dev-9+g671073e71

Additional context

I have fixed this already and created a pull request. https://github.com/nvim-orgmode/orgmode/pull/773

kristijanhusak commented 3 months ago

By visible you mean folded? Why would we ignore the folded ones?

SlayerOfTheBad commented 3 months ago

In nvim-orgmode, visibility of headlines is simulated using folding, since we don't have true invisible lines in neovim.

If my interface visually looks like an Emacs equivalent, I expect it to behave the same as the Emacs equivalent. So if I can see the headings for lines 2, 5, and 7, I expect next-visible-heading to bring me from 2 to 5, and not a folded line 4.

SlayerOfTheBad commented 3 months ago

I have updated the description with videos illustrating the difference in behaviour between nvim-orgmode and Emacs' Orgmode.

kristijanhusak commented 3 months ago

Thanks for the videos, now I understood the issue. Your PR is merged. Thanks!