Skip to content
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

Final newline insertion without wikilinks moves cursor #1361

Open
SanderBeekhuis opened this issue Jun 11, 2024 · 3 comments
Open

Final newline insertion without wikilinks moves cursor #1361

SanderBeekhuis opened this issue Jun 11, 2024 · 3 comments

Comments

@SanderBeekhuis
Copy link

SanderBeekhuis commented Jun 11, 2024

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:

  • You already have wikilinks
  • You already have a trailing newline
  • In general, when the cursor is not on the very final position in the file.

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
Copy link
Collaborator

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

  • i imagine disabling the extension fixes the problem? (just want to be sure the issue is coming from Foam :) )
  • do you have auto-save on? I was wondering if it's related to some sort of saving+document formatting (but that doesn't explain some of the scenarios you described)

@SanderBeekhuis
Copy link
Author

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
Copy link
Collaborator

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

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

No branches or pull requests

3 participants