mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
When PipeAsStringHandler is destroyed, ensure that we flush any pending data
Otherwise, we would not handle the last line if it didn’t end with a newline character.
This commit is contained in:
@@ -27,6 +27,14 @@ package actor PipeAsStringHandler {
|
||||
self.handler = handler
|
||||
}
|
||||
|
||||
deinit {
|
||||
if !buffer.isEmpty {
|
||||
queue.async { [handler, buffer] in
|
||||
handler(String(data: buffer, encoding: .utf8) ?? "<invalid UTF-8>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleDataFromPipeImpl(_ newData: Data) {
|
||||
self.buffer += newData
|
||||
while let newlineIndex = self.buffer.firstIndex(of: UInt8(ascii: "\n")) {
|
||||
|
||||
Reference in New Issue
Block a user