Repository navigation
Conversation
… overflows The menu was only shifted left when the cursor was in the right half of the editor. When the cursor was in the left half and the menu was too wide, Neovim clamped the float itself, but the stored geometry still held the requested column. The docs window is placed from that stored geometry, so it ended up on top of the menu. Clamp the column whenever the menu does not fit, so the stored geometry matches what Neovim draws and the docs view can find the free space (or close when there is none).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f6ac8bbba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.bottom_up = false | ||
| end | ||
| if math.floor(vim.o.columns * 0.5) <= col + border_offset_col and vim.o.columns - col - border_offset_col <= width then | ||
| if vim.o.columns - col - border_offset_col <= width then |
There was a problem hiding this comment.
Use the offset-adjusted column for overflow checks
When window.completion.col_offset is negative and already moves a left-half menu on screen, this new branch decides overflow from the unoffset col and then applies the offset again in the later open call. With 80 columns, col = 20, width = 65, no border, and col_offset = -10, the code before this change opened at 10 (ending at 75), but this condition now clamps col to 14 and the final window opens at 4; thus a menu that fit is shifted an extra six columns and no longer has the requested alignment. Perform the fit/clamp against the final offset-adjusted column.
Useful? React with 👍 / 👎.
…fset window.completion.col_offset was added after the fit check, so a negative offset that already brought the menu on screen still triggered the clamp and then moved it further left. Apply the offset first and check the fit at the column the menu actually opens at.
|
Good catch from the bot review: the fit check ran before |
Fixes #2232
Problem
custom_entries_view.openonly moves the menu left when the cursor is in the right half of the editor:When the cursor is in the left half and the menu is still too wide (a long item, or a narrow terminal as in the issue), the column is left as requested. Neovim then clamps the float on screen by itself, but
entries_win.style(and thereforeview:info()) still holds the requestedcol/width.docs_view.opencomputesleft_space/right_spacefrom thatinfo(), so it places the documentation window on what it thinks is free space, which is actually covered by the menu.Change
Drop the "right half" part of the condition: whenever the menu does not fit to the right of its column, apply the existing clamp (shift left, and shrink if it is wider than the editor). Menus that end before the last column are not touched (the same one-column margin the right-half case already used), and the right-half case behaves as before.
With that,
info()describes the geometry Neovim actually draws, and the docs view either finds the real free side or closes when there is no room (the "expected behavior" in the issue). This keeps the fix in the menu instead of reading backnvim_win_get_position, as suggested in the issue, and it can be tested headlessly.Tests
New
lua/cmp/view/custom_entries_view_spec.lua:vim.o.columnsvim.o.columnsThe first two fail without the change and pass with it.
vusted ./luapasses (76 successes) with Neovim 0.11.4,luacheck luareports 0 warnings, andstylua --checkis clean on the changed files.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to help projects with open issues. The change was prepared with Claude Code and verified as listed above. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it, please feel free to close it, no hard feelings at all 🙂