denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.01k stars 5.39k forks source link

Formatter messes up indentation, even its own #26956

Closed Stokestack closed 17 hours ago

Stokestack commented 1 day ago

deno 2.0.6 (stable, release, aarch64-apple-darwin) v8 12.9.202.13-rusty typescript 5.6.2

I'm using the Deno plug-in for VS Code. When cutting and pasting code, something is messing up the indentation of function bodies, adding an extra level. Also, when pressing Return after a function signature, the first line is similarly indented an extra level... despite the "format selection" command previously having put the rest of the body at the correct position. Screen grab attached.

Here's what I have for formatting in deno.json:

  "fmt": {
    "useTabs": true,
    "lineWidth": 120,
    "indentWidth": 4,
    "semiColons": true,
    "proseWrap": "always"
  },

https://github.com/user-attachments/assets/14999ab5-bb15-4af2-aa56-02aa06a3a293

dsherret commented 1 day ago

Are you sure Deno is configured as your formatter? I don't think "format selection" is implemented. Do you have format on save enabled? What's causing the format to occur? It kind of looks like vscode from the video. Can you provide the actions you're taking to reproduce this? (ex. what keys are you pressing)

Stokestack commented 1 day ago

Thanks for the follow-up. It's not happening on saving, so I don't think that's related. "Format selection" is doing stuff, so I don't know what you mean by not implemented.

I'm using normal cut & paste keys. On Mac, that's Command-X, Command-V.

I noted that I'm using the Deno plug-in for VS Code, so it's possible that the bug is there. But I have no way of determining that (as far as I know).

dsherret commented 1 day ago

I think that's just vscode then. It probably happens with the deno extension being disabled.

Stokestack commented 1 day ago

It's not disabled. What do you mean?

dsherret commented 1 day ago

I mean my guess is if you disable the deno vscode extension then you'll probably still see the behaviour you describe.

I don't believe the Deno extension formats except on save and only if it's configured to.

Stokestack commented 17 hours ago

Thanks! And, in fact that's true. I wonder what is messing it up. I don't find any relevant option in the VS Code settings.

Anyway, closing this.