@@ -25,12 +25,8 @@ static std::string GetStringFromStructuredData(lldb::SBStructuredData &data,
2525 return std::string ();
2626
2727 const size_t length = keyValue.GetStringValue (nullptr , 0 );
28-
29- if (length == 0 )
30- return std::string ();
31-
3228 std::string str (length + 1 , 0 );
33- keyValue.GetStringValue (&str[0 ], length + 1 );
29+ keyValue.GetStringValue (&str[0 ], length);
3430 return str;
3531}
3632
@@ -68,38 +64,19 @@ void ProgressEventThreadFunction(DAP &dap) {
6864 const uint64_t total = GetUintFromStructuredData (data, " total" );
6965 const std::string details =
7066 GetStringFromStructuredData (data, " details" );
71-
67+ std::string message;
68+ // Include the title on the first event.
7269 if (completed == 0 ) {
73- if (total == 1 ) {
74- // This progress is non deterministic and won't get updated until it
75- // is completed. Send the "message" which will be the combined title
76- // and detail. The only other progress event for thus
77- // non-deterministic progress will be the completed event So there
78- // will be no need to update the detail.
79- const std::string message =
80- GetStringFromStructuredData (data, " message" );
81- dap.SendProgressEvent (progress_id, message.c_str (), completed,
82- total);
83- } else {
84- // This progress is deterministic and will receive updates,
85- // on the progress creation event VSCode will save the message in
86- // the create packet and use that as the title, so we send just the
87- // title in the progressCreate packet followed immediately by a
88- // detail packet, if there is any detail.
89- const std::string title =
90- GetStringFromStructuredData (data, " title" );
91- dap.SendProgressEvent (progress_id, title.c_str (), completed, total);
92- if (!details.empty ())
93- dap.SendProgressEvent (progress_id, details.c_str (), completed,
94- total);
95- }
96- } else {
97- // This progress event is either the end of the progress dialog, or an
98- // update with possible detail. The "detail" string we send to VS Code
99- // will be appended to the progress dialog's initial text from when it
100- // was created.
101- dap.SendProgressEvent (progress_id, details.c_str (), completed, total);
70+ const std::string title = GetStringFromStructuredData (data, " title" );
71+ message += title;
72+ message += " : " ;
10273 }
74+
75+ message += details;
76+ // Verbose check, but we get -1 for the uint64 on failure to read
77+ // so we check everything before broadcasting an event.
78+ if (message.length () > 0 )
79+ dap.SendProgressEvent (progress_id, message.c_str (), completed, total);
10380 }
10481 }
10582 }
0 commit comments