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

Formatting not working on Windows #694

Closed
tomwyr opened this issue Feb 26, 2024 · 3 comments · Fixed by #802
Closed

Formatting not working on Windows #694

tomwyr opened this issue Feb 26, 2024 · 3 comments · Fixed by #802

Comments

@tomwyr
Copy link

tomwyr commented Feb 26, 2024

The formatting does not seem to work properly when compiled on Windows. The compilation went smoothly, however, when used as CLI as well as together with vscode formatter, the behavior is incorrect:

  • Running swift-format command from bash/powershell hangs without any output and never completes.
  • Running Format document With with apple-swift-format empties content of the editor the formatting is run on.

Tested on

  • Windows 11 (10.0.22631 Build 22631)
  • Swift 5.9.2
  • swift-format 509.0.0
  • apple-swift-format 1.4.3
@ahoppen
Copy link
Member

ahoppen commented Apr 23, 2024

Tracked in Apple’s issue tracker as rdar://126948386

@kkebo
Copy link
Contributor

kkebo commented Oct 7, 2024

This infinite loop occurred not only on Windows, but also on other platforms.

For example, on Linux, candidateDirectory.path changed as follows.

  • /foo/bar/baz
  • /foo/bar
  • /foo
  • (empty string)
  • (empty string)
  • (empty string)
  • ...

So it couldn't match / forever.

Fortunately, #802 seems to fix the issue on Linux as well. I hope that this fix will ship as soon as possible.

By the way, I think the following behavior is the root cause.

$ swift repl 
Welcome to Swift version 6.0.2-dev (LLVM 43d73cb0cc589f7, Swift aaa632cea622394).
Type :help for assistance.
  1> import Foundation
  2> URL(filePath: "/foo", directoryHint: .notDirectory).deletingLastPathComponent().path
$R0: String = "/"
  3> URL(filePath: "/foo", directoryHint: .isDirectory).deletingLastPathComponent().path 
$R1: String = ""

@omochi
Copy link

omochi commented Oct 8, 2024

That’s due to this bug.
swiftlang/swift-foundation#922

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

Successfully merging a pull request may close this issue.

4 participants