vknabel / vscode-swiftformat

SwiftFormat for VS Code
https://marketplace.visualstudio.com/items?itemName=vknabel.vscode-swiftformat
MIT License
39 stars 7 forks source link

Fix "File not found" on Windows #25

Closed hf02 closed 11 months ago

hf02 commented 1 year ago

This fixes #21 (again?).

As it turns out, the error was due to SwiftFormat taking the path as relative. You can see this here:

> swiftformat C:\Users\o_o\Desktop\projects\swift\test\Sources\main.swift
error: File not found at C:/Users/o_o/Desktop/projects/swift/test/Sources/C:/Users/o_o/Desktop/projects/swift/test/Sources/main.swift.

My solution was just to put a / in front of the path if on Windows. SwiftFormat takes it as absolute and it formats it fine.

Tested on Windows 11.