Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lldb/source/Core/CoreProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ let Definition = "debugger", Path = "" in {
def ShowProgress
: Property<"show-progress", "Boolean">,
Global,
DefaultFalse,
DefaultTrue,
Desc<"Whether to show progress using Operating System Command (OSC) "
"Sequences in supporting terminal emulators.">;
Comment thread
JDevlieghere marked this conversation as resolved.
def ShowProgressAnsiPrefix: Property<"show-progress-ansi-prefix", "String">,
Expand Down
27 changes: 26 additions & 1 deletion lldb/source/Core/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,30 @@ void Debugger::CancelForwardEvents(const ListenerSP &listener_sp) {
m_forward_listener_sp.reset();
}

/// Conservative heuristic to detect whether OSC 9;4 progress is supported by
/// the current terminal.
static bool TerminalSupportsOSCProgress() {
static std::once_flag g_once_flag;
static bool g_supports_osc_progress = false;

std::call_once(g_once_flag, []() {
std::array<const char *, 4> g_known_env_vars = {
Comment thread
JDevlieghere marked this conversation as resolved.
Outdated
"WT_SESSION", // Windows Terminal
Comment thread
JDevlieghere marked this conversation as resolved.
Outdated
"ConEmuPID", // ConEmu
"GHOSTTY_RESOURCES_DIR", // Ghostty
"OSC_PROGRESS", // Override
Comment thread
JDevlieghere marked this conversation as resolved.
Outdated
};
for (const char *env_var : g_known_env_vars) {
if (std::getenv(env_var)) {
g_supports_osc_progress = true;
return;
}
}
});

return g_supports_osc_progress;
}

bool Debugger::IsEscapeCodeCapableTTY() {
if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {
File &file = stream_sp->GetUnlockedFile();
Expand Down Expand Up @@ -2305,7 +2329,8 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
}

// Show progress using Operating System Command (OSC) sequences.
if (GetShowProgress() && IsEscapeCodeCapableTTY()) {
if (GetShowProgress() && IsEscapeCodeCapableTTY() &&
TerminalSupportsOSCProgress()) {
if (lldb::LockableStreamFileSP stream_sp = GetOutputStreamSP()) {

// Clear progress if this was the last progress event.
Expand Down