fix text truncation on conceal text in popup windows #19121
+118
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using
concealfeature inside popup windows with fixed width, text is incorrectly truncated before reaching the popup'smaxwidth. This happens because the conceal mechanism usesboguscolsto track "phantom columns" for concealed characters, causing the rendering logic to think the line has reached the window width earlier than it actually has.Reproduction
Run the following script:
Current (Incorrect) Output
The text is truncated at "hidde" (40 characters including the concealed "SECRET" word's phantom space), cutting off "n." from "hidden."
Expected Output
The full text should be displayed within the 40-character width, since "SECRET" (6 chars) is concealed to a single space, making the actual visible text 37 characters.
Root Cause
In
drawline.c, the conceal handling for wrapped lines usesboguscolsto track phantom columns. The logic advances bothwlv.colandwlv.boguscolsto maintain consistent cursor positioning in normal windows. However, for popup windows with fixedmaxwidth, this causes premature line wrapping because:wlv.colis incremented for each concealed character (to maintain cursor position)wlv.col >= wp->w_width, the line is considered full and wrapsSolution
For popup windows with fixed width, skip the
boguscolsandcoladjustments during conceal processing. This allows the actual visible content to determine when the line should wrap, rather than including phantom columns in the calculation.The fix adds a check
!WIN_IS_POPUP(wp)before adjustingwlv.colandwlv.boguscolsin the conceal handling code, ensuring popup windows render concealed text correctly while maintaining the existing behavior for normal windows (where cursor position calculations depend on these adjustments).