diff --git a/src/libs/utils/terminalhooks.h b/src/libs/utils/terminalhooks.h index b37c51517c0..dbc42dea511 100644 --- a/src/libs/utils/terminalhooks.h +++ b/src/libs/utils/terminalhooks.h @@ -41,6 +41,20 @@ enum class ExitBehavior { Close, Restart, Keep }; struct OpenTerminalParameters { + OpenTerminalParameters() = default; + OpenTerminalParameters(const CommandLine &commandLine) : shellCommand(commandLine) {} + OpenTerminalParameters(const FilePath &directory, std::optional env) : + workingDirectory(directory), + environment(env) + {} + OpenTerminalParameters(const CommandLine &commandLine, + const FilePath &directory, + std::optional env) : + shellCommand(commandLine), + workingDirectory(directory), + environment(env) + {} + std::optional shellCommand; std::optional workingDirectory; std::optional environment; diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index 3df3309c318..8b1a5122d35 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -106,7 +106,7 @@ void FileUtils::showInFileSystemView(const FilePath &path) void FileUtils::openTerminal(const FilePath &path, const Environment &env) { - Terminal::Hooks::instance().openTerminal({std::nullopt, path, env}); + Terminal::Hooks::instance().openTerminal({path, env}); } QString FileUtils::msgFindInDirectory() diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 0b57384ea22..b68121ca02e 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3630,7 +3630,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env BuildConfiguration *bc = activeBuildConfiguration(ProjectTree::projectForNode(currentNode)); if (!bc) { - Terminal::Hooks::instance().openTerminal({{}, currentNode->directory(), environment}); + Terminal::Hooks::instance().openTerminal({currentNode->directory(), environment}); return; } @@ -3649,7 +3649,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env if (!shell.isEmpty() && buildDevice->rootPath().needsDevice()) { Terminal::Hooks::instance().openTerminal({CommandLine{shell, {}}, workingDir, environment}); } else { - Terminal::Hooks::instance().openTerminal({std::nullopt, workingDir, environment}); + Terminal::Hooks::instance().openTerminal({workingDir, environment}); } } @@ -3684,7 +3684,7 @@ void ProjectExplorerPluginPrivate::openTerminalHereWithRunEnv() Terminal::Hooks::instance().openTerminal( {CommandLine{shell, {}}, workingDir, runnable.environment}); } else { - Terminal::Hooks::instance().openTerminal({std::nullopt, workingDir, runnable.environment}); + Terminal::Hooks::instance().openTerminal({workingDir, runnable.environment}); } } diff --git a/src/plugins/terminal/shellmodel.cpp b/src/plugins/terminal/shellmodel.cpp index 0b13b0f8863..d5caa415dd3 100644 --- a/src/plugins/terminal/shellmodel.cpp +++ b/src/plugins/terminal/shellmodel.cpp @@ -162,7 +162,7 @@ QList ShellModel::remote() const const QList deviceItems = Utils::transform( deviceCmds, [](const Utils::Terminal::NameAndCommandLine &item) -> ShellModelItem { - return ShellModelItem{item.name, {}, {item.commandLine, std::nullopt, std::nullopt}}; + return ShellModelItem{item.name, {}, {item.commandLine}}; }); return deviceItems; diff --git a/src/plugins/terminal/terminalprocessimpl.cpp b/src/plugins/terminal/terminalprocessimpl.cpp index b5d116ec48b..f26383dfade 100644 --- a/src/plugins/terminal/terminalprocessimpl.cpp +++ b/src/plugins/terminal/terminalprocessimpl.cpp @@ -40,11 +40,9 @@ public: TerminalWidget *terminal = m_terminalPane->stoppedTerminalWithId(id); - const OpenTerminalParameters openParameters{setup.m_commandLine, - std::nullopt, - std::nullopt, - ExitBehavior::Keep, - id}; + OpenTerminalParameters openParameters{setup.m_commandLine}; + openParameters.m_exitBehavior = ExitBehavior::Keep; + openParameters.identifier = id; if (!terminal) { terminal = new TerminalWidget(nullptr, openParameters);