llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) <details> <summary>Changes</summary> Add an optional `bool foreground` parameter to `Host::OpenFileInExternalEditor` so callers can choose whether opening the file should bring the editor to the foreground. The macOS implementation maps `foreground=true` to omitting `kLSLaunchDontSwitch` in the Launch Services flags, so the editor is brought forward on launch. On non-Apple platforms the stub still returns `ENOTSUP`; the new parameter is added to its signature so it matches the declaration. --- Full diff: https://github.com/llvm/llvm-project/pull/209331.diff 3 Files Affected: - (modified) lldb/include/lldb/Host/Host.h (+2-1) - (modified) lldb/source/Host/common/Host.cpp (+1-1) - (modified) lldb/source/Host/macosx/objcxx/Host.mm (+4-3) ``````````diff diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 632614c17d173..554be4386adc3 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -309,7 +309,8 @@ class Host { static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, - uint32_t line_no); + uint32_t line_no, + bool foreground = false); /// Open a URL with the host's default handler (Launch Services on macOS, /// xdg-open on other Unix). Returns an error if opening fails or the platform diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 81d45f78559ce..c4e1500fe68ab 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -610,7 +610,7 @@ void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); } #if !defined(__APPLE__) llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, - uint32_t line_no) { + uint32_t line_no, bool foreground) { return llvm::errorCodeToError( std::error_code(ENOTSUP, std::system_category())); } diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm index 9aae821220939..2553c602bea2c 100644 --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -341,7 +341,7 @@ repeat with the_window in (get windows)\n\ llvm::Error Host::OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, - uint32_t line_no) { + uint32_t line_no, bool foreground) { #if !TARGET_OS_OSX return llvm::errorCodeToError( std::error_code(ENOTSUP, std::system_category())); @@ -432,8 +432,9 @@ repeat with the_window in (get windows)\n\ // Build app launch parameters. LSApplicationParameters app_params; ::memset(&app_params, 0, sizeof(app_params)); - app_params.flags = - kLSLaunchDefaults | kLSLaunchDontAddToRecents | kLSLaunchDontSwitch; + app_params.flags = kLSLaunchDefaults | kLSLaunchDontAddToRecents; + if (!foreground) + app_params.flags |= kLSLaunchDontSwitch; if (app_fsref) app_params.application = &(*app_fsref); `````````` </details> https://github.com/llvm/llvm-project/pull/209331 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
