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

Folding a header, or inside a header, randomly folds the entire file below, including higher level headers #1396

Open
2 tasks done
noctopixi opened this issue Apr 19, 2024 · 3 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@noctopixi
Copy link

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

0.9.5

Neorg setup

I use Lazy and source the config from nvim-neorg.lua.
Lazy reports that Neorg is at version 8.4.1

return {
	"nvim-neorg/neorg",
	dependencies = { "luarocks.nvim" },
	opts = {
		load = {
			["core.defaults"] = {},
			["core.concealer"] = {},
			["core.export"] = {},
			["core.keybinds"] = {
        config = {
          hook = function(keybinds)
          keybinds.map("all", "n", "<LocalLeader>ll", "<cmd>Neorg keybind all core.looking-glass.magnify-code-block<CR>")
          end,
        }
      },
			["core.dirman"] = {
				config = {
					workspaces = {
						notes = "~/Notes",
						personal = "~/Personal",
					},
					default_workspace = "notes",
				},
			},
			["core.journal"] = {
				config = {
					workspace = "personal",
					-- journal_folder = "journal",
				},
			},
		},
	},
	lazy = false,
	version = "*", -- Pin Neorg to the latest stable release
	config = true,
}

Actual behavior

Sometimes, given my cursor being on the name or the contents of any header, including lower level headers like level 3 headers...
When I press za/zc to fold the header, EVERYTHING below it is folded, including higher hierarchy headers such as level 1 and 2 headers.
It happens even if I add --- or === to mark the end of a header's contents.

EXAMPLE:
Folding a level 3 header results in EVERYTHING below getting folded, including the level 2 header which should remain unfolded because it has a higher hierarchy.

Before
image
After
image

Expected behavior

Given my cursor being inside of a fold, or on a header that can be folded...
When I press za / zc it should only fold itself and its contents (including any lower level headers).
It should never fold any higher level headers below it.

Strangely, if I ggVG + dp to copy and paste the entire file on top of itself, or on a new .norg file, folds work as expected insofar I don't add or modify any new content, header text or header hierarchy. The screenshots below, with the expected behavior, were taken after using this workaround.

EXAMPLE OF EXPECTED BEHAVIOR
Before
image
After
image

Steps to reproduce

To reproduce the bug:

  • Open a norg file
  • Modify the name of a header, or its contents, or add subheaders (like adding a level 3 header inside a level 2 one).
  • Press za or zc with the cursor on the header's name, or within its contents.
  • The entire file below will fold.

To reproduce the behavior expected at all times:

  • Either open a .norg file with folds and do not modify its contents.
    OR
  • Once a .norg file with folds has the folding issue described above, copy the entire file via deleting or yanking.
  • Delete the contents of the entire file
  • Paste what you just copied, either on the same file or a different one.
  • Toggle some folds. They will work as expected and fold only its contents, not the entire file below them.

Potentially conflicting plugins

I don't think I use any plugins that directly affect folding behavior. I haven't changed my Neovim plugins recently, except for my colorscheme (now using Catppuccin Macchiato).

Other information

  • I'm running Fedora 39, and I'm using nvim 0.9.5. I installed Neorg via Lazy and use vhyrro's luarocks.nvim.

  • I have tried toggling the concealer off but it doesn't fix the issue, only re-pasting the entire file does.

  • As requested in CONTRIBUTING.md, here is a copy of my neorg.log. I no longer have the Otter plugin installed.

[ERROR Sat 06 Apr 2024 11:53:46 PM CST] ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:240: Error when executing `:Neorg otter` - such a command does not exist!
[ERROR Sat 06 Apr 2024 11:53:58 PM CST] ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:240: Error when executing `:Neorg otter` - such a command does not exist!
[ERROR Sun 07 Apr 2024 12:03:50 AM CST] ...im/lazy/neorg/lua/neorg/modules/core/neorgcmd/module.lua:240: Error when executing `:Neorg otter` - such a command does not exist!

  • My neorg is pinned to the latest release.

  • Modules list

- `core.neorgcmd.commands.return`
- `core.keybinds.keybinds`
- `core.ui`
- `core.dirman.utils`
- `core.ui.text_popup`
- `core.tangle`
- `core.storage`
- `core.qol.todo_items`
- `core.qol.toc`
- `core.promo`
- `core.pivot`
- `core.looking-glass`
- `core.journal`
- `core.esupports.metagen`
- `core.dirman`
- `core.esupports.hop`
- `core.clipboard.code-blocks`
- `core.clipboard`
- `core.keybinds`
- `core.export`
- `core.concealer`
- `core.defaults`
- `core.autocommands`
- `core.integrations.treesitter`
- `core.ui.selection_popup`
- `core.esupports.indent`
- `core.concealer.preset_basic`
- `core.itero`
- `core.mode`
- `core.highlights`
- `core.concealer.preset_diamond`
- `core.concealer.preset_varied`
- `core.neorgcmd`

Help

No

Implementation help

While I cannot really submit a PR with a code fix, I'm happy to help with testing and provide any additional information that might help. Thanks for your time and help!

@noctopixi noctopixi added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Apr 19, 2024
@benlubas
Copy link
Contributor

I'm unable to reproduce the issue following your instructions (on 9.5 or nightly).

Folding is known to be buggy, most often :e (just re-opening the file) fixes it. Also tested with/without ufo, and it still doesn't reproduce the issue.

How consistent is the reproduction for you?

@lars-vc
Copy link

lars-vc commented Apr 20, 2024

It happens quite frequently but not on every level 3 header, seems like it can't be the last level 3 header and also not the first.
:e does fix it.
I have ufo installed but turned off in norg files.

@noctopixi
Copy link
Author

Hi! I haven't noticed it in level 3 headers only, but on the entire file. I am still unsure as to what causes it to occur.
I need to use Neorg today, if/when the problem comes up, I will try recording a video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

3 participants