dprint / dprint-intellij

A dprint plugin for Intellij.
https://plugins.jetbrains.com/plugin/18192-dprint
MIT License
15 stars 2 forks source link

Does not work in Rider #58

Open provegard opened 1 year ago

provegard commented 1 year ago

I haven't managed to get the dprint plugin to work in Rider. It works in IDEA without any problems.

In Rider, unlike in IDEA, I have to specify the dprint executable manually. That's fine.

When I change a file by introducing some unwanted whitespace changes and then save, I get:

2023 08 28 08:01:51:  Initialising editor service
2023 08 28 08:01:52:  Received editor info: {"schemaVersion":5,"cliVersion":"0.40.2","configSchemaUrl":"https://dprint.dev/schemas/v0.json","plugins":[]}

2023 08 28 08:01:52:  Received schema version 5
2023 08 28 08:01:52:  Initializing EditorServiceV5
2023 08 28 08:01:52:  Clearing message 16
2023 08 28 08:01:52:  Clearing message 17
2023 08 28 08:01:52:  Clearing message 14
2023 08 28 08:01:52:  Starting editor service with executable C:\kod\Customer\Product\node_modules\dprint\dprint.exe, config C:\kod\Customer\Product\dprint.json and working directory C:\kod\Customer\Product.
2023 08 28 08:01:52:  Priming can format cache for C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs
2023 08 28 08:01:52:  Checking if C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs can be formatted.
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Reading file: C:\Users\perro\AppData\Local\dprint\cache\plugin-cache-manifest.json
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Creating directory: C:\Users\perro\AppData\Local\dprint\cache\locks
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Reading file: C:\kod\Customer\Product\dprint.json
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Reading file: C:\Users\perro\AppData\Local\dprint\cache\plugins\dprint-plugin-typescript\0.86.2-4.0.0-x86_64
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Reading file: C:\Users\perro\AppData\Local\dprint\cache\plugins\dprint-plugin-json\0.17.4-4.0.0-x86_64
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Reading file: C:\Users\perro\AppData\Local\dprint\cache\plugins\dprint-plugin-vue\0.5.0-4.0.0-x86_64
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Checking path exists: C:\Users\perro\AppData\Local\dprint\cache\plugins\dprint-plugin-roslyn\0.16.0\x86_64\dprint-plugin-roslyn.exe
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Creating instance of dprint-plugin-typescript
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Creating instance of dprint-plugin-vue
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Creating instance of dprint-plugin-roslyn
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Created instance of dprint-plugin-json in 6ms
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Created instance of dprint-plugin-typescript in 8ms
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Created instance of dprint-plugin-roslyn in 76ms
2023 08 28 08:01:52:  Dprint daemon 49540: [VERBOSE] Checking can format: C:\kod\Customer\Product\src\Suite\Model.Product\Model\Item\Item.Nullable.cs
2023 08 28 08:01:52:  C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs can be formatted
2023 08 28 08:01:58:  Running save action on C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs.
2023 08 28 08:01:58:  Running save action on C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs.
2023 08 28 08:01:58:  Creating formatting task for C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs
2023 08 28 08:01:58:  Formatting C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs
2023 08 28 08:01:58:  Created formatting task for C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs with id 19
2023 08 28 08:01:58:  Dprint daemon 49540: [VERBOSE] Host formatting C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs - File length: 1582 - Plugins: [dprint-plugin-roslyn] - Range: None
2023 08 28 08:01:58:  Creating formatting task for C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs
2023 08 28 08:01:58:  Formatting C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs
2023 08 28 08:01:58:  Created formatting task for C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs with id 20
2023 08 28 08:01:58:  Dprint daemon 49540: [VERBOSE] Host formatting C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs - File length: 1582 - Plugins: [dprint-plugin-roslyn] - Range: None
2023 08 28 08:01:58:  Successfully formatted C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs

Note how it says "Successfully formatted C:/kod/Customer/Product/src/Suite/Model.Product/Model/Item/Item.Nullable.cs". However, the file does not change at all.

If I run npx dprint fmt src/Suite/Model.Product/Model/Item/Item.Nullable.cs, the file gets formatted.

This is my dprint config:

{
  "lineWidth": 120,
  "indentWidth": 4,
  "useTabs": false,
  "newLineKind": "auto",
  "typescript": {
    "semiColons": "asi",
    "quoteProps": "consistent",
    "parameters.trailingCommas": "never",
    "arguments.trailingCommas": "never",
    "exportDeclaration.trailingCommas": "never",
    "typeLiteral.separatorKind.singleLine": "comma"
  },
  "json": {
    "lineWidth": 80
  },
  "vue": {
  },
  "roslyn": {
    "csharp.spaceAfterCast": true,
    "csharp.wrappingKeepStatementsOnSingleLine": false
  },
  "includes": [
    ...other paths...,
    "**/src/Suite/Model.Product/**/*.cs"
  ],
  "excludes": [
    ...other paths...,
    "**/obj/**",
    "**/bin/**"
  ],
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.86.2.wasm",
    "https://plugins.dprint.dev/json-0.17.4.wasm",
    "https://plugins.dprint.dev/malobre/vue-v0.5.0.wasm",
    "https://plugins.dprint.dev/roslyn-0.16.0.json@a508b0823fa356a33b43fc071e1cebe4a9c9ded12ca2f84c46ba67e2a3f13487"
  ]
}

I'm using Rider 2023.1.1, Build #RD-231.8770.54.

ryan-rushton commented 1 year ago

Weird, it might be an Rider issue rather than an issue with this plugin. OOI have you tried any other formatter and had success?

The reason I ask is that log line should only be appearing if

  1. Content has changed
  2. The file content was passed to dprint, which reformatted it and passed new content back
  3. The virtual file was successfully updated and saved without error.

If it is getting there and you aren't seeing the update in the UI it feels like that file save wasn't actually successful.

I don't have a copy of Rider but I might ask Jetbrains if I can get one to debug this. Also, contributions welcome :)