[lldb/Interpreter] Open saved transcript in GUI Editor
This patch will automatically open LLDB's saved transcript file on the graphical editor if lldb is running under an interactive graphical session. This can be controlled by a new setting: `interpreter.open-transcript-in-editor` rdar://92692106 Differential Revision: https://reviews.llvm.org/D137137 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
parent
cb30072a72
commit
902ba8b0c9
|
@ -559,6 +559,9 @@ public:
|
|||
bool GetSaveSessionOnQuit() const;
|
||||
void SetSaveSessionOnQuit(bool enable);
|
||||
|
||||
bool GetOpenTranscriptInEditor() const;
|
||||
void SetOpenTranscriptInEditor(bool enable);
|
||||
|
||||
FileSpec GetSaveSessionDirectory() const;
|
||||
void SetSaveSessionDirectory(llvm::StringRef path);
|
||||
|
||||
|
|
|
@ -170,6 +170,17 @@ void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
|
|||
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
|
||||
}
|
||||
|
||||
bool CommandInterpreter::GetOpenTranscriptInEditor() const {
|
||||
const uint32_t idx = ePropertyOpenTranscriptInEditor;
|
||||
return m_collection_sp->GetPropertyAtIndexAsBoolean(
|
||||
nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
|
||||
}
|
||||
|
||||
void CommandInterpreter::SetOpenTranscriptInEditor(bool enable) {
|
||||
const uint32_t idx = ePropertyOpenTranscriptInEditor;
|
||||
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
|
||||
}
|
||||
|
||||
FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
|
||||
const uint32_t idx = ePropertySaveSessionDirectory;
|
||||
return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
|
||||
|
@ -3226,6 +3237,13 @@ bool CommandInterpreter::SaveTranscript(
|
|||
result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
|
||||
output_file->c_str());
|
||||
|
||||
if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
|
||||
const FileSpec file_spec;
|
||||
error = file->GetFileSpec(const_cast<FileSpec &>(file_spec));
|
||||
if (error.Success())
|
||||
Host::OpenFileInExternalEditor(file_spec, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ let Definition = "interpreter" in {
|
|||
Global,
|
||||
DefaultFalse,
|
||||
Desc<"If true, LLDB will save the session's transcripts before quitting.">;
|
||||
def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
|
||||
Global,
|
||||
DefaultTrue,
|
||||
Desc<"If true, LLDB will open the saved session's transcripts in the external editor.">;
|
||||
def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
|
||||
DefaultStringValue<"">,
|
||||
Desc<"A path where LLDB will save the session's transcripts. This is particularly useful when you can't set the session file, for example when using `save-session-on-quit`.">;
|
||||
|
|
Loading…
Reference in New Issue