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

fix(eval): open the floating window under the cursor #332

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lua/dapui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ function dapui.eval(expr, args)
prev_expr = expr
local elem = dapui.elements.hover
elem.set_expression(expr, args.context)
local line_no = async.fn.screenrow()
local col_no = async.fn.screencol()
Comment on lines -189 to -190
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

screenrow() and screencol() always seem to output 1.

See here: neovim/neovim#15754 (comment)

local position = { line = line_no, col = col_no }
local win_pos = async.api.nvim_win_get_position(0)
local position = {
line = win_pos[1] + async.fn.winline(),
col = win_pos[2] + async.fn.wincol() - 1,
Copy link
Contributor Author

@toh995 toh995 Feb 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes an off-by-one error (0-indexing vs. 1-indexing)

}
open_float = require("dapui.windows").open_float("hover", elem, position, args)
if open_float then
open_float:listen("close", function()
Expand Down