diff --git a/kate/kateapp.cpp b/kate/kateapp.cpp --- a/kate/kateapp.cpp +++ b/kate/kateapp.cpp @@ -175,7 +175,10 @@ KTextEditor::Document *doc = nullptr; const QString codec_name = codec ? QString::fromLatin1(codec->name()) : QString(); - Q_FOREACH(const QString positionalArgument, m_args.positionalArguments()) { + // Bug 397913: Reverse the order here so the new tabs are opened in same order as the files were passed in on the command line + QString positionalArgument; + for (int i = m_args.positionalArguments().count() - 1; i >= 0; --i) { + positionalArgument = m_args.positionalArguments().at(i); UrlInfo info(positionalArgument); // this file is no local dir, open it, else warn diff --git a/kate/main.cpp b/kate/main.cpp --- a/kate/main.cpp +++ b/kate/main.cpp @@ -416,7 +416,9 @@ QStringList tokens; // open given files... - foreach(const QString & url, urls) { + // Bug 397913: Reverse the order here so the new tabs are opened in same order as the files were passed in on the command line + for (int i = urls.size() - 1; i >= 0; --i) { + const QString &url = urls[i]; QDBusMessage m = QDBusMessage::createMethodCall(serviceName, QStringLiteral("/MainApplication"), QStringLiteral("org.kde.Kate.Application"), QStringLiteral("tokenOpenUrlAt"));