heyman / heynote

A dedicated scratchpad for developers
https://heynote.com
Other
3.86k stars 194 forks source link

Bug: Cursor moves to the bottom of the page if the buffer is modified in another app #165

Open gerroon opened 8 months ago

gerroon commented 8 months ago

Describe the bug Modifying the buffer in another app makes Heynote to change the cursor's position all the way to the bottom

To Reproduce Steps to reproduce the behavior: move the cursor all the way up in the page, add some text and let it stay there open and modify the buffer.txt by adding anew line at the top watch for heynote's reloading of the changes

Expected behavior It should never change the current location or the view of the page regardless of any change. However in this case the change is done at the top so it should at least goto where they change is Desktop (please complete the following information):

heyman commented 8 months ago

Yes, so far I've kept it simple and avoided implementing any kind of diffing logic to try to find where the cursor should go to make it feel like it stays in the same position after the buffer file has changed on disk.

It should never change the current location or the view of the page regardless of any change.

Do you mean that the cursor should stay at the exact same place, character count-wise? E.g. if the cursor is at position 4000 in the buffer, it should still be at position 4000 after the update? What if the new changes have inserted additional data at the top? What if the file has completely changed?

gerroon commented 8 months ago

The cursor is at 0 before the modification, after the modification reload the cursor goes to 4000 (the bottom of the page). Should not it stay at 0? Bear in mind it does not matter where the change has been it always goes to the bottom of the page after the modif, even if you just add a word at the top.

I do not think we need a diff implementation, we just need to make sure the cursor does not change to random places, even if it was modified in another app.

heyman commented 8 months ago

Well, for the case where the cursor is either at the beginning or at the end of the buffer, that would work. For other cases, you would have to implement some kind of logic to determine where the cursor should go.

gerroon commented 8 months ago

My point is that the cursor should never move (stays at where it is) after an update rather than trying to figure out where it should go.

heyman commented 8 months ago

Do you mean that the cursor should stay at the exact same place, character count-wise? E.g. if the cursor is at position 4000 in the buffer, it should still be at position 4000 after the update? What if the new changes have inserted additional data at the top? What if the file has completely changed?

Victor239 commented 6 months ago

I think it should stay simple and there be a preference for it to be at the bottom or top line.

The way I use my scratchpad is that the most important stuff stays at the top, the least important is at the bottom. It's annoying that the cursor keeps moving to the very bottom to the irrelevant stuff rather than staying at the top.

gerroon commented 6 months ago

I agree with @Victor239, at the moment cursor always jumpts to bottom, even when the app is started. I profer the cursor to be at the top at least.