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

newLineKind system doesn't work #94

Open
provegard opened this issue Nov 6, 2024 · 5 comments
Open

newLineKind system doesn't work #94

provegard opened this issue Nov 6, 2024 · 5 comments

Comments

@provegard
Copy link

Hi!

I have the following dprint.json:

{
    "lineWidth": 120,
    "indentWidth": 4,
    "useTabs": false,
    "newLineKind": "system",
    "typescript": {
        "semiColons": "asi",
        "quoteProps": "consistent",
        "parameters.trailingCommas": "never",
        "arguments.trailingCommas": "never",
        "exportDeclaration.trailingCommas": "never",
        "typeLiteral.separatorKind.singleLine": "comma"
    },
    "plugins": [
        "https://plugins.dprint.dev/typescript-0.93.2.wasm"
    ]
}

I'm on Windows, so newlines are CRLF.

When I save the following file with format on save enabled...

const x = {foo: 42}

image

...I get the following error:

2024-11-06 19:09:42,163 [ 437098]   INFO - #com.dprint.services.editorservice.EditorServiceTaskQueue - Creating formatting task for C:/kod/projects/dprint-test/src/file.js
2024-11-06 19:09:42,163 [ 437098]   INFO - #com.dprint.services.editorservice.v5.EditorServiceV5 - Formatting C:/kod/projects/dprint-test/src/file.js
2024-11-06 19:09:42,163 [ 437098]   INFO - #com.dprint.services.editorservice.v5.EditorServiceV5 - Created formatting task for C:/kod/projects/dprint-test/src/file.js with id 14
2024-11-06 19:09:42,163 [ 437098] SEVERE - #com.dprint.services.editorservice.process.StdErrListener - Dprint daemon 34936: [DEBUG] Host formatting C:/kod/projects/dprint-test/src/file.js - File length: 20 - Plugins: [dprint-plugin-typescript] - Range: None
2024-11-06 19:09:42,163 [ 437098] SEVERE - #com.dprint.services.editorservice.process.StdErrListener - IntelliJ IDEA 2024.2.4  Build #IU-242.23726.103
2024-11-06 19:09:42,163 [ 437098] SEVERE - #com.dprint.services.editorservice.process.StdErrListener - JDK: 21.0.4; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2024-11-06 19:09:42,163 [ 437098] SEVERE - #com.dprint.services.editorservice.process.StdErrListener - OS: Windows 11
2024-11-06 19:09:42,163 [ 437098] SEVERE - #com.dprint.services.editorservice.process.StdErrListener - Last Action: EditorCopy
2024-11-06 19:09:42,163 [ 437098]   INFO - #com.dprint.services.editorservice.v5.EditorServiceV5 - Successfully formatted C:/kod/projects/dprint-test/src/file.js
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - Exception in thread "Thread-99" java.lang.AssertionError: Wrong line separators: '... foo: 42 }\r\n' at offset 21
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.util.text.StringUtil.assertValidSeparators(StringUtil.java:2552)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.editor.impl.DocumentImpl.assertValidSeparators(DocumentImpl.java:717)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.editor.impl.DocumentImpl.replaceString(DocumentImpl.java:607)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.editor.impl.DocumentImpl.lambda$setText$3(DocumentImpl.java:1087)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:217)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:178)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:168)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:154)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.editor.impl.DocumentImpl.setText(DocumentImpl.java:1092)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.dprint.services.FormatterServiceImpl.format$lambda$2$lambda$1$lambda$0(FormatterService.kt:60)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.WriteCommandAction.lambda$runWriteCommandAction$4(WriteCommandAction.java:341)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$1(WriteCommandAction.java:147)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction$lambda$4(AnyThreadWriteThreadingSupport.kt:318)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:328)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:318)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:890)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$2(WriteCommandAction.java:145)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:226)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:188)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:154)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$run$0(WriteCommandAction.java:125)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:229)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:22)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread$lambda$1(AnyThreadWriteThreadingSupport.kt:184)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread(AnyThreadWriteThreadingSupport.kt:183)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:836)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:424)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:101)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithImplicitRead(AnyThreadWriteThreadingSupport.kt:122)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.ApplicationImpl.runWithImplicitRead(ApplicationImpl.java:1162)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:78)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:119)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:696)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$16(IdeEventQueue.kt:590)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithoutImplicitRead(AnyThreadWriteThreadingSupport.kt:117)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:590)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:73)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:357)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1$1.compute(IdeEventQueue.kt:356)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:843)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:356)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.invoke(IdeEventQueue.kt:351)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke$lambda$0(IdeEventQueue.kt:1035)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.WriteIntentReadAction.lambda$run$0(WriteIntentReadAction.java:24)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:84)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteIntentReadAction(ApplicationImpl.java:910)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.WriteIntentReadAction.compute(WriteIntentReadAction.java:55)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.WriteIntentReadAction.run(WriteIntentReadAction.java:23)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueueKt$performActivity$runnableWithWIL$1.invoke(IdeEventQueue.kt:1035)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:1036)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:106)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:1036)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$10(IdeEventQueue.kt:351)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:397)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
2024-11-06 19:09:42,195 [ 437130]   INFO - STDERR - 	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

I'm not sure if this is a problem in the plugin or IDEA.

If I change to auto, formatting works as expected, but auto has other problems on Windows, so it'd be nice if system worked. Note that system works fine when dprint is invoked from the console.

@ryan-rushton
Copy link
Collaborator

ryan-rushton commented Dec 5, 2024

I'm not sure if this is a problem in the plugin or IDEA.

@provegard it would be the plugin, the IJ extension simply starts up a process using a command line util IJ provides and passes the config to it. It seems as if the actual plugin itself needs some kind of update to make sure that the new lines are handled accordingly

@ryan-rushton
Copy link
Collaborator

@dsherret do you have any insights on the above?

@dsherret
Copy link
Member

dsherret commented Dec 9, 2024

Yeah, it's dprint/dprint-plugin-typescript#499

@dsherret
Copy link
Member

dsherret commented Dec 9, 2024

Ah, i should read the issue. One minute :D

@dsherret
Copy link
Member

dsherret commented Dec 9, 2024

I'm not sure what's causing this one.

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