Skip to content

fix(#2746): background and right aligned icons in floating windows #3128

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

Merged

Conversation

simonmandlik
Copy link
Collaborator

@simonmandlik simonmandlik commented May 16, 2025

Closes #2746

Also I added functionality for copying over right-aligned icons to the float.

Before:

Screenshot 2025-05-16 at 8 48 57

After:

Screenshot 2025-05-16 at 8 47 58

@simonmandlik simonmandlik requested a review from alex-courtis May 16, 2025 07:14
@simonmandlik
Copy link
Collaborator Author

On second thought, copying over right aligned icons is not a very good idea—they are nearly always visible anyway and as implemented in this PR, they might be copied in a different order than in the tree window.

I pushed another commit getting rid of that copying.

There is also one more improvement in the condition when to show the full name in float. It now takes into account also right aligned icons.

Before:

image

After:

image

@alex-courtis
Copy link
Member

On second thought, copying over right aligned icons is not a very good idea—they are nearly always visible anyway and as implemented in this PR, they might be copied in a different order than in the tree window.

Good call. It's non-trivial and doesn't really add much value.

@alex-courtis
Copy link
Member

There is also one more improvement in the condition when to show the full name in float. It now takes into account also right aligned icons.

Apologies, I think I might not be understanding; it seems to be adding whitespace to the float, for the right icons:

-- vim.opt.culopt = "number"
require("nvim-tree").setup({
  view = {
    width = 18,
  },
  renderer = {
    full_name = true,
    icons = {
      git_placement = "right_align",
      modified_placement = "right_align",
      hidden_placement = "right_align",
      diagnostics_placement = "right_align",
      bookmarks_placement = "right_align",
    },
  },
})

No icon:
20250518_142545

Icon:
20250518_142629

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Great work as always @simonmandlik

please:

  • move extmarks_length to util
  • fix the annotation nit

@@ -302,6 +302,21 @@ function M.open(options)
log.profile_end(profile)
end

---@param extmarks table
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
---@param extmarks table
---@param vim.api.keyset.get_extmark_item[] as per vim.api.nvim_buf_get_extmarks

@@ -302,6 +302,21 @@ function M.open(options)
log.profile_end(profile)
end

---@param extmarks table
---@return number
function M.extmarks_length(extmarks)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for abstracting this.

Small request: move this to utils.lua. View is being converted into a stateful explorer member as part of the multi-instance view initiative: #3109

@alex-courtis
Copy link
Member

Apologies, my time is limited, I'll look at this next weekend.

…puting condition for full name float to show
@simonmandlik
Copy link
Collaborator Author

simonmandlik commented May 18, 2025

There is also one more improvement in the condition when to show the full name in float. It now takes into account also right aligned icons.

Apologies, I think I might not be understanding; it seems to be adding whitespace to the float, for the right icons:

-- vim.opt.culopt = "number"
require("nvim-tree").setup({
  view = {
    width = 18,
  },
  renderer = {
    full_name = true,
    icons = {
      git_placement = "right_align",
      modified_placement = "right_align",
      hidden_placement = "right_align",
      diagnostics_placement = "right_align",
      bookmarks_placement = "right_align",
    },
  },
})

No icon: 20250518_142545

Icon: 20250518_142629

Thanks for pointing that out, there was a bug, which now should be fixed. This PR, besides fixing #2746, also fixes this behavior:

master:
image

image

PR:
image

image

@simonmandlik simonmandlik requested a review from alex-courtis May 18, 2025 09:21
Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

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

Many thanks for the thorough fix!

@alex-courtis alex-courtis changed the title fix(#2746): fix cursorcolumn and right aligned icons in floating windows fix(#2746): fix background and right aligned icons in floating windows May 24, 2025
@alex-courtis alex-courtis changed the title fix(#2746): fix background and right aligned icons in floating windows fix(#2746): background and right aligned icons in floating windows May 24, 2025
@alex-courtis alex-courtis merged commit cbc3165 into master May 24, 2025
6 checks passed
@alex-courtis alex-courtis deleted the 2746-float-window-for-full-filenames-has-wrong-bg branch May 24, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Float window for full filenames has wrong bg
2 participants