Skip to content

fix(files): ensure that file-preview includes the first column - #2515

Merged
echasnovski merged 1 commit into
nvim-mini:mainfrom
abeldekat:files_fix_preview
Jul 19, 2026
Merged

fix(files): ensure that file-preview includes the first column#2515
echasnovski merged 1 commit into
nvim-mini:mainfrom
abeldekat:files_fix_preview

Conversation

@abeldekat

Copy link
Copy Markdown
Member

Resolve #2514

Test Preview works for files has been modified to also include the case where the preview did not start from zero cursor position. As a consequence, I had to regenerate some screenshots in test cases also using the real_path directory.

@abeldekat
abeldekat requested a review from echasnovski July 18, 2026 09:38
@abeldekat abeldekat changed the title fix(files): ensure that file-preview starts at zero cursor position fix(files): ensure that file-preview starts at zero cursor column Jul 18, 2026
@abeldekat
abeldekat force-pushed the files_fix_preview branch from 2cf47f6 to 0e3fe65 Compare July 18, 2026 09:43

@echasnovski echasnovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

I'd like to try to find the exact culprit of the problem instead of using *.h file.

Comment thread tests/dir-files/real/long-line.h Outdated
Comment thread lua/mini/files.lua Outdated
@echasnovski

Copy link
Copy Markdown
Member

Oh, I only now have seen the second edit of this comment. The culprit is that the file contains a line with three or more / which are recognized as special indicators in directory buffers. This information is definitely needed in the commit message at least.

If that's the case, then I the more appropriate solution is to not tweak cursor when window shows a buffer for a file. And instead of adding a new file, prepending the a.txt test file with the wide line that contains three slashes with a text explanation in between is a less intrusive and more direct way to test this.

I think inlining the H.window_set_cursor() directly into the only place it is used is more beneficial here, since it can reuse the H.fs_get_type(buf_data.path) data to determine if the cursor needs to be tweaked.

@abeldekat
abeldekat force-pushed the files_fix_preview branch from 0e3fe65 to 7a32ee4 Compare July 18, 2026 18:40
@abeldekat

Copy link
Copy Markdown
Member Author

I pushed a new commit.

For the test I used b.txt...

@abeldekat abeldekat changed the title fix(files): ensure that file-preview starts at zero cursor column fix(files): ensure that file-preview includes the first column Jul 18, 2026

@echasnovski echasnovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Already much better! Both the code+test changes and the commit message. There are still small tweaks to make it more polished.

Comment thread tests/dir-files/real/b.txt Outdated
Comment thread lua/mini/files.lua Outdated
@abeldekat
abeldekat force-pushed the files_fix_preview branch 2 times, most recently from b2e4cd8 to ea7b5a7 Compare July 18, 2026 20:35
Details:
- Preview position for a file should always include the first column.
  When the first line of a file is long and has 3 slashes, the text
  shown in preview started from another column, hiding text to the left.
  The solution is to not 'tweak' the cursor when the window shows
  a file.

Resolve nvim-mini#2514

@echasnovski echasnovski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on this!

@echasnovski
echasnovski merged commit a35f08f into nvim-mini:main Jul 19, 2026
12 checks passed
@abeldekat
abeldekat deleted the files_fix_preview branch July 19, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mini.files] preview sometimes starts at a non-zero column position

2 participants