Code keeps auto formatting while typing

Hi,

When I'm typing, it seems like PhpStorm keeps reformatting the code. This happens in all file types.

I've uploaded an example of a js file: Upload id: 2023_08_01_qYSydTEr29MBQoq9vYfas2 (file: phpstorm64_3HZuMKnZVK.mp4)

How do I disable this? This didn't happen before.

1
14 comments

Did you figure this out? It seems to happen in non-php files

0

Hi there,

1. Any File Watchers?

2. What active entries do you have at "Settings/Preferences | Tools | Actions on Save"?

3. Do you use custom External Formatter? "Settings/Preferences | PHP | Quality Tools"

0

Hi,

1. Yes, but only for .less files explicitly, without any wildcards and they can be set to show when running, which they are not in these instances.

2. Only the .less file watchers

3. "No External Formatter" is checked.

The formatting appears to only be soft - in that whilst there is indentation changing and spaces are elided or added the dots for displaying spaces do not match and opening the file outside of PhpStorm those displayed auto-formatted whitespace are not actually present in the file. It does not appear to be waiting until save to do this formatting, it happens within a second of pausing typing.

Tabbing (I have 4 - spaces for tab) adds four dots to an indented section at a time but the indentation is retained.

Added trailing whitespace is "removed" but if you backspace at the end of the line it removes the concealed whitespace, and trailing whitespace can be seen in the file outside of PhpStorm.

This affects, in my experience, files with .js and .twig for sure, but not .php files so far.

This appears to have arrived in the most recent version (or one of the most recent as I have auto-updating enabled) - this was occurring in the EA version recently (I upgraded to check a feature regarding docblocks out and downgraded when this occurred, assuming it was a bug) and in the last week or so it has started happening in the Release version.

 

0

Rich Hobbs

In such a case I'm not really sure what this might be.

It could be Prettier for example. But if nothing is enabled in the "Actions on Save"...

It does not appear to be waiting until save to do this formatting, it happens within a second of pausing typing.

The behaviour is similar to the File Watcher TBH. Could be some external tool/linter integration as well (ESLint/Prettier or alike) -- they usually run after about 1-2 secs delay after stopping typing.

Right now I may only suggest you check your Quality Tools settings and other stuff that can auto run -- disable them and see if this will make any difference.

P.S. Do you use "show asterisk * on modified tabs" option? It marks modified but not yet saved files with that symbol. Does that symbol changes at all when this happens?

P.P.S. What if you make a brand new empty project and copy a few files where this is happening in the existing project -- will it start happening there as well. In theory, empty project has nothing to "auto configure"...

0

Prettier is disabled

The sequence is:

  1. typing
  2. stop
  3. reformatting occurs
  4. unsaved icon appears on tab (it's a circle symbol; the option is called "Mark modified" under Editor > General > Editor Tabs, not to be pedantic but in case this is different in different versioning that might assist in determining cause/origin)
  5. unsaved icon disappears as auto-save occurs (auto save is set to 3 seconds idle)

It is noticeably faster than file-watchers in terms of the response/delay.

No external tools are running.

JSHint was enabled, but disabling does not stop this occurring.

A new project doesn't seem to have this problem - I don't know how to determine what is running that is causing this.

 

0

No better ideas on what it might be right now. IMO this has to be one of the tools but which one?.. Cannot really suggest more than this (without playing with the Settings screen myself in such a project / another pair of eyes may spot something that original one ignored/filters out).

Other than that:

  • Try "Help | Collect Logs and Diagnostic Data" and then check the files. It should give some hints.
  • Can also try "Help | Diagnostic Tools | Activity Monitor..." -- see which process may popup there.
  • Try some process monitor tool (if you are on Windows -- try ProcMon from SysInternals tool (now Microsoft) -- see which tools it tries to run at that moment (if it's an external tool ofc).

 

the option is called "Mark modified" under Editor > General > Editor Tabs, not to be pedantic but in case this is different in different versioning that might assist in determining cause/origin)

Yeah. It's now called "Mark modified (*)" in my 2023.1.4. The New UI may use different symbol than traditional UI themes that I'm using. Used to have different name years ago: "Mark modified tabs with asterisk":

(screenshot is from StackOverflow answer from 2013...)

 

0

Ok, so I have found the source(s) of the problem(s) I think:

I disabled all downloaded plugins, and restarted PhpStorm, but still had the problem.

Disabled Javascript and Typescript (bundled 232.8660.205) and restarted PhpStorm - js files now no-longer reformat.

Twig files still reformatting in the annoying way.

Disabled Twig plugin (bundled 232.8660.205) - twig files now no-longer reformatting.

Running macOS Ventura 13.5 (22G74)
PhpStorm 2023.2
Build #PS-232.8660.205, built on July 28, 2023
Runtime version: 17.0.7+7-b1000.6 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.5
GC: G1 Young Generation, G1 Old Generation
Memory: 3584M
Cores: 8
Metal Rendering is ON
Registry:
    debugger.new.tool.window.layout=true
    run.processes.with.pty=TRUE
    documentation.show.toolbar=true
    ide.experimental.ui=true
    ide.balloon.shadow.size=0

No file watchers and could find no configuration for these plugins which would prevent this from happening - very irritating as even if you can put up with the annoying constant re-ordering of the display, the displayed indentation/layout is not actually accurate unless you also indent the files by adding the appropriate tabbing/spaces.

Downgraded to:
PhpStorm 2023.1.4
Build #PS-231.9225.18, built on July 12, 2023
Runtime version: 17.0.7+10-b829.16 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.5
GC: G1 Young Generation, G1 Old Generation
Memory: 750M
Cores: 8
Metal Rendering is ON
Registry:
    debugger.new.tool.window.layout=true
    run.processes.with.pty=TRUE
    documentation.show.toolbar=true
    ide.experimental.ui=true
    ide.balloon.shadow.size=0

and the behaviour has gone away, even with the two offending plugins re-enabled.

Hopefully this will get fixed in a future version, or the appropriate settings/options can be found to configure this to behave in a more sensible manner.

0

We don't really have similar reports so far; at least, I couldn't find any.

To fix the issue, we need first to understand it, but I think Andriy has gone through all possible causes already.

Here's a couple more things to try:

  1. Make a copy of an affected project and remove the .idea folder from the copy. Will the issue still be there in this copy?
  2. If it is, please also check how it goes with the default config (File | Manage IDE Settings | Restore Default Settings).
    You can import your original config later via File | Manage IDE Settings | Import Settings.
1

I have a similar issue on the project when I edit files in excluded folder.

the above solution helps but... it wipes all the settings you have on the project((

putting .idea back from backup makes the issue appear again.

https://www.dropbox.com/s/qpb7m2d3wh4xtiu/screencast%202023-08-14%2018-12-54.mp4?dl=0

0

Unfortunately, I can't tell what is going on there without being able to reproduce the issue.
As a test, could you please make a copy of the project that won't include the 'vendor' and 'node_modules' folders and check if the issue is still there in the copy?
If it is, could you please share the '.idea' folder together with your 'composer.json'?

0

I can't reproduce it either now) I've downgraded and upgraded back PphStrom version and this bug gone away.

0

I have it constantly for all web development files, javascript/vue/css/html. They all auto-format while typing, if i for instance type “<input ” it will remove the space before i can type id="" for instance. which it will then say <inputid="" which then auto-formats back to <input id="". also when i want to write  a new line i do 3 tabs so it will be in line with the code, but it automatically removes all tabs before i can start typing text. Then when i type it automatically shifts to the place it should be. But, this is only visually. in reality there are still the amount of tabs i did. soo for instance if my code has an indent of 8 spaces (for me 2 tabs) and i add 16 spaces by mistake, it will auto move the code to 8 spaces, but when i save this and look in git, it will have 16 spaces.

I just want my control back, HELP! D:

I'm on the brink of reverting my phpstorm to 2023.1 because it only went wrong after 2023.2

0

It was actually fixed in PHPstorm 2023.2.1 update that came out recently :)

0

Still, no idea what it was. Thank you for the update!

0

Please sign in to leave a comment.