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

Error when opening link-not-found #1215

Closed
2 tasks done
Rik034 opened this issue Dec 10, 2023 · 3 comments
Closed
2 tasks done

Error when opening link-not-found #1215

Rik034 opened this issue Dec 10, 2023 · 3 comments
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@Rik034
Copy link

Rik034 commented Dec 10, 2023

Prerequisites

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

Neovim Version

v0.9.4

Neorg setup

require("neorg").setup({
	load = {
		["core.defaults"] = {}, -- Loads default behaviour
		["core.concealer"] = { -- Adds pretty icons to your documents
			config = {
				icon_preset = "diamond",
			},
		},
		["core.dirman"] = { -- Manages Neorg workspaces
			config = {
				workspaces = {
					main = "~/Documents/neorg/main",
				},
				default_workspace = "main",
			},
		},
	},
})

Actual behavior

I get an error when pressing enter on a link which doesn't exist.
Watershot_10-12-2023_08:04

Expected behavior

The 'link-not-found' buffer should open

Steps to reproduce

Press enter on a link which doesn't exist

Potentially conflicting plugins

Maybe barbar.nvim messes with the buffers?

Other information

No response

Help

No

Implementation help

No response

@Rik034 Rik034 added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Dec 10, 2023
@pysan3
Copy link
Contributor

pysan3 commented Dec 10, 2023

@vhyrro This is coming from this commit: 603b633 where you added the the second argument keybind_buffer to core.ui.selection_popup.begin_selection.

As you can see here:

.begin_selection(module.required["core.ui"].create_split("link-not-found"))

core.ui.create_split returns two values tuple[buf, window] where with the old code, the second value window was ignored, but with the new change, window is passed as keybind_buffer which is definitely not intended.

What I'm confused tho is that even though you added this change, I don't see a place that calls the above function with two arguments, so this change was only added to introduce this error lol.

Could you explain why you made this change @vhyrro ?

Second, more verbose code is always better and we should've done something like this, especially when we silently ignore a return value (purposely).

local link_not_found_buf = module.required["core.ui"].create_split("link-not-found")

local selection = module.required["core.ui"]
    .begin_selection(link_not_found_buf)
    :listener({
    "<Esc>",
    }, function(self)
      ...

Reference:

local function foo(a, b)
    vim.print(string.format([[a: %s]], vim.inspect(a)))
    vim.print(string.format([[b: %s]], vim.inspect(b)))
    vim.print(string.format([[b or a: %s]], vim.inspect(b or a)))
end

local function two_rets()
    return 10, 20
end

local args = two_rets()
foo(args)       -- a = 10, b = nil

foo(two_rets()) -- a = 10, b = 20

-- BTW you can wrap `two_rets` with parens `()` to purposefully fetch only the first return value,
-- but this is not well-known and I don't think this is documented anywhere in lua docs lol

foo((two_rets())) -- a = 10, b = nil

@vhyrro
Copy link
Member

vhyrro commented Dec 27, 2023

Should be fixed now! @pysan3 the change was introduced as it's necessary for the upcoming GTD implementation which can be found in the not-so-hidden gtd branch. That's where the new function invocation syntax was used :)

@pysan3
Copy link
Contributor

pysan3 commented Dec 27, 2023

I see. Yah, can't wait to see gtd coming!

Thanks for fixing it.

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