================
@@ -311,10 +309,22 @@ void DAP::SendOutput(OutputType o, const llvm::StringRef
output) {
category = "telemetry";
break;
}
- body.try_emplace("category", category);
- EmplaceSafeString(body, "output", output.str());
- event.try_emplace("body", std::move(body));
- SendJSON(llvm::json::Value(std::move(event)));
+
+ // Send each line of output as an individual event, including the newline if
+ // present.
+ ::size_t idx = 0;
+ do {
+ ::size_t end = output.find('\n', idx);
+ if (end == llvm::StringRef::npos)
+ end = output.size() - 1;
+ llvm::json::Object event(CreateEventObject("output"));
+ llvm::json::Object body;
+ body.try_emplace("category", category);
+ EmplaceSafeString(body, "output", output.slice(idx, end + 1).str());
+ event.try_emplace("body", std::move(body));
+ SendJSON(llvm::json::Value(std::move(event)));
+ idx = end + 1;
+ } while (idx < output.size());
----------------
ashgti wrote:
VS Code append to the previous lines if the previous line don't end in a `\n`
or `\r\n`
(https://github.com/microsoft/vscode/blob/d193e4b6f525e90911df21f8f1820cf0fe0fda0c/src/vs/workbench/contrib/debug/common/replModel.ts#L306).
With the previous version of this, if we had an output event like `abc\ndef`
followed by `foo\n`, these would have been merged into a single 'output' item
in the UI. With this change it will instead have `abc\n` as one output item and
`deffoo\n` would become a second output item.
I can also increase the buffer size for the reads.
https://github.com/llvm/llvm-project/pull/105456
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits