8000 Fix cursor location when printing statline by joelim-work · Pull Request #1348 · gokcehan/lf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix cursor location when printing statline #1348

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
merged 4 commits into from
Aug 7, 2023
Merged

Fix cursor location when printing statline #1348

merged 4 commits into from
Aug 7, 2023

Conversation

joelim-work
Copy link
Collaborator

This PR fixes a few bugs with the cursor location when printing the statline:

  • The prefix can contain double-width characters when deleting a file that includes such characters in its name, and this case is not handled properly because the prefix is handled as a string instead of a []rune.
    • Create a file containing Chinese characters such as 一二三四五六七八九十.
    • Bring up the deletion prompt by typing :delete.
  • The size of the left isn't calculated properly, as ui.cmdAccLeft is a []rune but is indexed using cell indexes.
    • Type : followed by some Chinese text (e.g. 一二三四五六七八九十) until it overflows the UI.
  • The size of the shell-pipe output is not taken into account when truncating left for > prompts, so the cursor can go past the end of the screen.
    • Run %printf 'type something: ' && read ans
    • Type until the text overflows the UI.

@joelim-work
Copy link
Collaborator Author
joelim-work commented Jul 27, 2023

Additionally for the second point, I have found that typing : followed by a sufficiently long string of Chinese text (decreasing the width of the terminal helps to reproduce this) causes lf to crash:

Tested on version r30:

panic: runtime error: slice bounds out of range [101:96]

goroutine 1 [running]:
main.(*ui).draw(0xc0002b82c0, 0xc0002fa000)
	/build/lf/src/lf/ui.go:975 +0xc6f
main.(*app).loop(0xc000132b40)
	/build/lf/src/lf/app.go:459 +0x1013
main.run()
	/build/lf/src/lf/client.go:61 +0x33b
main.main()
	/build/lf/src/lf/main.go:330 +0x7b9

@joelim-work joelim-work merged commit b3ac207 into gokcehan:master Aug 7, 2023
@joelim-work joelim-work deleted the fix-statline-cursor branch August 7, 2023 07:43
@gokcehan gokcehan mentioned this pull request Sep 17, 2023
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.

1 participant
0