foambubble / foam

A personal knowledge management and sharing system for VSCode
https://foambubble.github.io/
Other
15.16k stars 649 forks source link

Final newline insertion without wikilinks moves cursor #1361

Open SanderBeekhuis opened 2 months ago

SanderBeekhuis commented 2 months ago

Describe the bug

When editing a markdown file and pausing for ~1sec with the cursor on the final position of the file the cursor jumps to a newly inserted newline.

This leads to the sentence to be broken into a new part when i continue typing.

I don't mind the insertion of newline that much (tough I don't like it either), but the movement of the cursor disturbs my flow.

If I can contribute in any way to solve this issue I would be willing to look into it and thanks for the hard work on the extension.

Small Reproducible Example

No response

Steps to Reproduce the Bug or Issue

When editing a markdown file, where | will indicate cursor position.

This is a markdown file I'm writing. 
Now I will pause to think how to continue this sentence|

Then after a brief pause (~1 sec) a newline is inserted and the cursor jumps to this new line.

Like this

This is a markdown file I'm writing. 
Now I will pause to think how to continue this sentence
|

This behavior does not happen when:

Expected behavior

  1. As a user I expected the cursor position to stay the same, but I'm seeing it move down one line.

  2. As a user I'm ambivalent about the insertion of a new trailing newline, but I would expect foam to not change files unnecessarily.

Screenshots or Videos

No response

Operating System Version

Seen this happen on both Linux and Windows (reporting for linux)

Visual Studio Code Version

Version: 1.89.1 Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:16:23.416Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 6.1.52-valve16-1-neptune-61

Additional context

No response

riccardoferretti commented 2 months ago

Thanks for reporting this, super odd. A couple of questions:

SanderBeekhuis commented 2 months ago

Hi @riccardoferretti, thanks for your response.

  1. I found that Foam was the issue with the "extension bisect" feature by VScode, and I just verified that disabling foam stops the issue from occuring.
  2. I do run a combination of "files.autoSave": "afterDelay" and "editor.formatOnSave": true . If I turn the extension back on and change to "files.autoSave": "off" the issue only occurs when manually saving (i.e. with Ctrl+S)

This leads me to think that the issue is indeed in the formatter that runs on document save. If you by chanhe know where that is located in this code-base I could also look into that myself.

As an additional note (and to make the behaviour even more curious) :

The following has no issues

First line

Single line after newline | 

and the following has:

First line

Two lines
after newline | 
pderaaij commented 1 month ago

@SanderBeekhuis could you list the active extensions in your workspace?