brokenbytes
(Marcel Kulina)
December 13, 2022, 4:05pm
#1
I started working on a simple integrated terminal for some project. I realised that, when using anything other than the default terminator "\n", print will always start from the beginning, no matter what has been printed before. The cursor does not advance and thus previous prints are overridden.
This behaviour is not present on macOS.
I opened an issue on GitHub:
opened 03:47PM - 13 Dec 22 UTC
bug
triage needed
**Description**
`print` does not work as intended on Windows. Running print wi… th anything other than the default terminator results in corrupted terminal output.
**Steps to reproduce**
- Create a new Swift Package Project
- Define an executable target
- Run multiple prints with `terminator` set to `""`
- No matter what has been written previously, the cursor will always start at 0, thus every print overrides the previous
**Example:**
```swift
public static func main() -> Void {
print("This is Text A", terminator: "")
print("This is Text B", terminator: "")
}
```
**Expected behavior**
The prints should get appended and the cursor should begin where the last print ended. This is the case for macOS.
Output from previous example on macOS:
`This is Text AThis is Text B`
Output from previous example on Windows:
`This is Text B`
**Environment**
macOS:
- Builtin Xcode 14 Compiler
- macOS 12.6.1
Windows:
- Swift Compiler Dev Snapshot 5.8
- Windows 11 latest
- Powershell/CMD
I will test if this behaviour is the same on the release stream. I will update the ticket then.
**Update**:
Also present on 5.7.1 release