Prettier-vscode: Cursor moving to end of file

Created on 8 Apr 2018  路  18Comments  路  Source: prettier/prettier-vscode

My cursor is moving randomly to the end of the file when I format my files.

Not sure if this is related but I am also having the same problems as in https://github.com/prettier/prettier-vscode/issues/290

When prettier does not run on save, I execute "Format Document" manually and then I notice the cursor moving to the end of the file. The screen does not scroll, just the cursor, but if I touch my keyboard keys then it will scroll, losing the position where I was working

locked

Most helpful comment

I'm seeing this in VSCode v1.33.0 on macOS v10.14.3.

The only formatter I'm using is prettier-vscode v1.8.1.

edit: This seems to be a VSCode issue: https://github.com/Microsoft/vscode/issues/71707

All 18 comments

I have the same issue.
I have disabled all extensions except Prettier and One Dark Pro, issue remains, no errors in console.

VSCode info:

Version 1.22.1
Commit 950b8b0d37a9b7061b6f0d291837ccc4015f5ecd
Date 2018-04-06T00:24:49.616Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Also happens on latest VSCode insiders build:

Version 1.23.0-insider
Commit 95101bf3f6d00105621cdddb639ea62b95ea2468
Date 2018-04-06T08:49:53.238Z
Shell 1.7.12
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Extension info:

Version 1.2.2

I've got no idea how to download a previous version and test it, otherwise I would try that.

System:

$ cat /proc/version
Linux version 4.10.0-38-generic (buildd@lgw01-amd64-059) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017

$ lsb_release -a
Distributor ID: LinuxMint
Description:    Linux Mint 18.3 Sylvia
Release:    18.3
Codename:   sylvia

$ cat /etc/debian_version
stretch/sid

I hope that helps, let me know if you need anything else.
Thanks in advance.

I am also having the same problem on Windows, but only one of my two development machines.
The problem occurs regardless of whether I have a project specific version of prettier installed (tried 1.10.2 and 1.11.1) or if I let the extension uses the shipped version of prettier (1.11.1).

I'm still trying to investigate any differences between my two machines.

I believe this unwanted behaviour only started occuring with the March update of VSCode (1.22).

I have to check it, but we are using the formatter API's from vscode. So I think that this is a problem with vscode or that we are using some incorrect options.

Does somebody have a small reproduction repository to test this? I can't reproduce it.

This may be highly related : https://github.com/Microsoft/vscode/issues/47382

I have this behavior sometimes but couldn't reproduce it reliably for now.

I also started seeing this lately. Not able to reproduce this consistently but happens multiple times a day. With both Javascript and Typescript. I think this started after the last VSCode release.

I have not managed to reproduce the error consistently but I've found out two things:

  1. Reverting back to vscode 1.21.1 solves the problem (at least so far)
  2. The cursor changes position only if prettier has made a modification.

Same problem here.
I also tried another prettier-plugin for VC Code. Same problem.

Seems consistent to me. I can reproduce like this:

  1. insert new line under current line (cmd-enter)
  2. save (with format-on-save activated)
  3. try to move cursor with arrow keys -> you'll be beamed directly to EOF.

It seems this is fixed in VSCode. We will need to wait for next 1.22 release

I had that issue and I can confirm it's fixed in version 1.22.2 recently published.

Fixed in VSCode 1.22.2

Same issue on 1.22.2

Can confirm, using visual studio code version 1.25.1 (1.25.1) and prettier plugin version 1.5.0.

Visual studio code settings for prettier are:

  "prettier.eslintIntegration": true,
  "editor.formatOnSave": false,
  "[javascript]": {
      "editor.formatOnSave": true
  },

@CiGit can you please reopen this issue?

@juhq do you have any other code formatting plugins? In my instance I thought it was prettier but the culprit was sort-imports and once disabled my cursor stopped jumping about.

@tim-hm sort-imports indeed is the culprit, thank you!

I'm seeing this in VSCode v1.33.0 on macOS v10.14.3.

The only formatter I'm using is prettier-vscode v1.8.1.

edit: This seems to be a VSCode issue: https://github.com/Microsoft/vscode/issues/71707

This is killing me right now.

I was having the same issue. I just go to the Installed Extensions and uninstall the "HTML & CSS FORMATTER" extension. Reload and it will work fine.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings