fix(border): Failing to display if row negative#240
fix(border): Failing to display if row negative#240l-kershaw merged 1 commit intonvim-lua:masterfrom
Conversation
|
Thanks for writing this PR 👍 I agree that this resolves the issue in most cases, but it seems to introduce problems when the popup is right at the top of the screen (so the border would go off the edge). Maybe something like: |
|
I see. Makes sense. I propose another solution, we could check the following:
I am not at my computer at the moment, so I might've used the wrong function, hopefully the intention is clear anyhow. I think this could also account for when the position is relative to the cursor and the border would be out of bounds once drawn. What do you think @l-kershaw ? |
|
@filipdutescu that seems like a good way to cover the edge cases to me 👍 |
|
I've just tested on my setup (seems like there is also an issue with
|
|
Ah, I think we would also need to adjust the "border thickness" at the top when we don't draw the top border. |
1a64862 to
6a05492
Compare
|
@l-kershaw do you have any idea why placement looks so weird? the values I have used for |
6a05492 to
4f39f42
Compare
|
@filipdutescu I can't reproduce your issue with "cursor-2" on row 3. Could you do a screen record of how you can reproduce it? Also, could you not keep force-pushing, it makes it harder to keep track of commits, and means that I need to keep approving the linting for you. We always squash PRs before merging into |
|
Yes, sure, sorry for force pushing, was trying to fix the styling issues, which seems to have ended in yet another failure. If you don't mind random I can do a screen record, but I am not sure how it will help without the underlying code. The code I am using to create the plugin is on a repo of mine. If you don't mind I can link it to you here, if that is OK with you of course. If not I could try and record the code as well? |
|
Don't worry about extra commits for linting, my PRs often have several commits trying to keep stylua happy 😅 It would be better if you could find a way to reproduce the issue using just the |
|
Will do, no problem. But how would you like to proceed? Shall I make a different PR for that issue (with steps to reproduce) and leave this as an encapsulated fix or use this PR for that as well? |
|
It seems like you still need to approve my runs, even without force-pushing, since I am not a contributor, yet (hopefully soon 🤞). |
|
I think the issue is related enough to this one to be in the same PR, particularly as we may have caused it here 😅 Yeh, I thought that it was the force-pushing that caused it, but clearly I was wrong 😅 |
|
Sure, just so I'm not appearing as MIA, I will experiment a bit, try to reproduce with only Anyways, just wanted to let you know I appreciate your promptness and willingness to help me and to get this fix working. So for that, thank you kindly! 😁 |
|
Sounds like a good plan to me 👍 No worries, very happy to help. Thanks for taking the initiative to write a PR 😃 |
|
@l-kershaw I managed to reproduce the issue with the current PR changes and with the latest Steps to reproduce
local popup = require'plenary.popup'
local tmp = {}
function tmp.make_popup()
local cword = vim.fn.expand '<cword>'
local prompt_col_no = 1
local prompt_line_no = 2
local title = 'Test'
local popup_opts = {
title = title,
padding = { 0, 0, 0, 0 },
border = true,
borderchars = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' },
width = #title + 4,
line = 'cursor-' .. prompt_line_no,
col = 'cursor-' .. prompt_col_no,
cursor_line = true,
enter = true,
callback = function() print('Hello World!') end,
}
print(popup_opts.line, popup_opts.col)
local prompt_win_id, prompt_opts = popup.create(cword, popup_opts)
vim.cmd [[startinsert]]
vim.api.nvim_win_set_option(prompt_win_id, 'wrap', false)
vim.api.nvim_win_set_option(prompt_win_id, 'winhl', 'Normal:Normal')
vim.api.nvim_win_set_option(prompt_win_id, 'winblend', 0)
return prompt_win_id, {
opts = popup_opts,
border_opts = prompt_opts.border
}
end
return tmp
ResultsCurrent PR changesWith the changes from the current PR the result was: Current
|
|
@l-kershaw also I would like to say that for a popup that appears on lines 1 and 2, it is fine to hide what's under the cursor and have a popup without border of 2 rows of height. It makes sense. So the border thickness thing you mentioned works wonderfully. The problem is only with the 3rd row, line 3. Personally, I would have it show the same as the previous 2, so no topline and 2 row height, starting from line 2. Does this make sense? Then again, this is not the previous behaviour, so maybe we should not handle it this way, but only make sure that the buffer text in put in the middle. Now that I think about it, this option seems better to me. I think it is from |
|
I do not have any settings for I really like the suggestion of using Does this change only need to be implemented for the |
|
Switching the second condition to |
|
Ah, I think you misunderstood my intention; |
|
Ah I see, now it makes a whole lot more sense haha. I will test it out tomorrow on my setup as well and let you know if everything is sound for me as well. Thanks! |
5537284 to
5703b3f
Compare
|
@l-kershaw I can confirm it fixes the issue for me as well: I have also squashed my commits, in order to preserve the messages describing what this PR aims to fix and how. Hope that's OK with you, if not feel free to change the message. |
This commit aims to fix an issue with the Border component, which makes it impossible to draw the top and bottom lines and makes the middle line replace the former, if the row is a negative value. The issues stems from an if condition which prevents top line from being created, if the row has a negative or 0 value. This also makes it impossible to use the `planery.popup` cursor-relative positioning, as a value such as 'cursor-2' would break the popup. It makes it so the if statement conditioning the rendering of a topline takes into account the boundaries of the current window, whether the position is absolute or cursor-relative. It also removes the top thickness of the hidden border, as pointed out by @l-kershaw. Finally, this commit ensures that cursor-relative position takes into account the editor-relative position of the cursor, not only the window one, as it lead to problems when not setting a certain `showtabline`. It also created an undesired behaviour of "pushing" the popup down, in order to make room for the topline.
5703b3f to
1e83cba
Compare
|
Thanks for all your hard work @filipdutescu! |
|
And thank you as well for your kind help and for accepting my changes! |








Fixes GH-239
Proposed changes
ifstatement checking that the row is positive and non-zero for aBorder, by allowing negative values for cursor-relative row numbers, if they are not outside of boundselsebranch to remove top border thickness if thetoplineshould not be drawnMotivation behind changes
As described in GH-239, this commit aims to fix an issue with the Border component, which makes it impossible to draw the top and bottom lines and makes the middle line replace the former, if the row is a negative value. This also makes it impossible to use the
planery.popupcursor-relative positioning, as a value such as 'cursor-2' would break the popup.Test plan
Tests from the
testsandlua/luassertdirectories are used for validation, as I am not too familiar with the current code base. If others should be made, please let me know so as to add them.