Fix read_console includeStacktrace parameter behavior (#304)
The includeStacktrace parameter was working backwards - when false, it would return the full message with embedded stack traces, and when true, it would extract the stack trace but the logic was inverted. Changes: - Always extract the first line as the message text - Only populate stackTrace field when includeStacktrace is true - Ensures clean, summary-only messages when includeStacktrace is false - Properly separates stack traces into their own field when requested This matches the expected Unity console behavior where the summary is shown by default, and stack traces are only shown when expanded.main
parent
5488af2c99
commit
ff736012fa
|
|
@ -304,14 +304,18 @@ namespace MCPForUnity.Editor.Tools
|
||||||
|
|
||||||
// --- Formatting ---
|
// --- Formatting ---
|
||||||
string stackTrace = includeStacktrace ? ExtractStackTrace(message) : null;
|
string stackTrace = includeStacktrace ? ExtractStackTrace(message) : null;
|
||||||
// Get first line if stack is present and requested, otherwise use full message
|
// Always get first line for the message, use full message only if no stack trace exists
|
||||||
string messageOnly =
|
string[] messageLines = message.Split(
|
||||||
(includeStacktrace && !string.IsNullOrEmpty(stackTrace))
|
|
||||||
? message.Split(
|
|
||||||
new[] { '\n', '\r' },
|
new[] { '\n', '\r' },
|
||||||
StringSplitOptions.RemoveEmptyEntries
|
StringSplitOptions.RemoveEmptyEntries
|
||||||
)[0]
|
);
|
||||||
: message;
|
string messageOnly = messageLines.Length > 0 ? messageLines[0] : message;
|
||||||
|
|
||||||
|
// If not including stacktrace, ensure we only show the first line
|
||||||
|
if (!includeStacktrace)
|
||||||
|
{
|
||||||
|
stackTrace = null;
|
||||||
|
}
|
||||||
|
|
||||||
object formattedEntry = null;
|
object formattedEntry = null;
|
||||||
switch (format)
|
switch (format)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue