glushchenko / fsnotes

Notes manager for macOS/iOS

Home Page:https://fsnot.es

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cursor jumps to the beginning of the Note

nburyak opened this issue · comments

Description

The cursor jumps to the beginning of the Note every time, when the title of the Note gets updated

To Reproduce

  1. Create new Note
  2. Start typing the text
    Actual Result: Every time, when the title of the Note gets updated, the cursor jumps to the beginning of the Note
REC-20240118101506.mp4

Expected behavior

The cursor should never be automatically moved during typing

FSNotes version

Version 6.6.6 (610) - (AppStore version)

macOS/iOS version

macOS 14.2.1 (23C71)

Additional context

No response

Can not reproduce it.

Try to change storage path to path without emoji.

Unfortunately, neither changing the location to default (which was actually set), nor removing the emojis in the path didn‘t help. Let me debug, maybe I‘ll find the rootcause

Also cannot reproduce. Please share a reproducible set of notes/folders.

You can also create a new user account on the same Mac to check if it happens there. If not, the problem is an app running in your user account.

I've debugged the code and figured out the following: while typing the text the Note gets reloaded and the cursor changes its position to 0 or previously saved position depending on the restoreCursorPosition value. I assume, this happens every time when the Note is saved to the file.

Here's the stack trace and the exact place of code, which causes cursor jumping during typing:
image

Another observation is restoring the position, which is different from the saved one. And this happens exactly during typing text (as I described above):

func saveCursorPosition() {
    ...
    NSLog(">>> saveCursorPosition:    \(length)")
    ...
}

func restoreCursorPosition() {
    ...
    NSLog(">>> restoreCursorPosition: \(position)")
    ...
}
2024-01-24 19:38:26.438408+0100 FSNotes[19008:5384306] >>> saveCursorPosition:    16
2024-01-24 19:38:26.712355+0100 FSNotes[19008:5384306] >>> saveCursorPosition:    17
2024-01-24 19:38:27.030987+0100 FSNotes[19008:5384306] >>> restoreCursorPosition: 8

I have a suspicion, the issue is related to the iCloud backup. Once I moved the Notes Storage outside of the iCloud folder, the issue was gone. Obviously, it doesn't help much because I want to sync my notes with the mobile phone. But this narrows down the problem

What about this option in the Settings? Did you try to enable it?

image

What about this option in the Settings? Did you try to enable it?

image
Restore.cursor.position.720.mov

With the Restore cursor position setting ON the cursor jumps a few symbols to the right, which is even worse, than jumping to the beginning of the Note.

I've posted the logs above: the cursor position in the func restoreCursorPosition() isn't same, as the last saved value in func saveCursorPosition(). It's definitely related to the iCloud sync but I can't find out how to fix this.

@nburyak please check this experimental build:

FSNotes_6.6.7.zip

Hi @glushchenko, thanks for the fix. I've just tested it - works much better now and doesn't mess with the text anymore 👍

Although, you may still notice a small glitch: in the word fixed I type the x character, then it disappears and re-appears again. I'd consider it a minor issue.

6.6.7.mov

OK, another try. Please test it and let me know.

FSNotes_6.6.7.zip

@glushchenko Thanks for the build - I can confirm, that in the latest version the issue is completely gone ✅

Is this fix planned for any of the upcoming AppStore releases?

Is this fix planned for any of the upcoming AppStore releases?

Yes