Commit 6e3c288f authored by Marcell Fülöp's avatar Marcell Fülöp
Browse files

When a document is oepened from a remote URL, wait for the ReadOnlyPart...

When a document is oepened from a remote URL, wait for the ReadOnlyPart completed() signal before setting cursor position passed on command line.
parent a2e1204a
......@@ -254,25 +254,7 @@ bool KateApp::startupKate()
activeKateMainWindow()->viewManager()->activateView(doc);
}
int line = 0;
int column = 0;
bool nav = false;
if (m_args.isSet(QStringLiteral("line"))) {
line = m_args.value(QStringLiteral("line")).toInt() - 1;
nav = true;
}
if (m_args.isSet(QStringLiteral("column"))) {
column = m_args.value(QStringLiteral("column")).toInt() - 1;
nav = true;
}
if (nav && activeKateMainWindow()->viewManager()->activeView()) {
activeKateMainWindow()->viewManager()->activeView()->setCursorPosition(KTextEditor::Cursor(line, column));
}
activeKateMainWindow()->setAutoSaveSettings();
setCursorFromArgs();
return true;
}
......@@ -353,9 +335,43 @@ KTextEditor::Document *KateApp::openDocUrl(const QUrl &url, const QString &encod
KMessageBox::sorry(mainWindow, i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", url.url()));
}
// When opening from remote url, 'completed' is emitted
// once loading has finished. Set requested --line/--column
// cursor position after this signal as doing so in startupKate()
// only has an affect on synchronously loaded local files.
connect(doc, SIGNAL(completed()), this, SLOT(remoteDocumentLoaded() ));
return doc;
}
void KateApp::remoteDocumentLoaded()
{
setCursorFromArgs();
}
void KateApp::setCursorFromArgs()
{
int line = 0;
int column = 0;
bool nav = false;
if (m_args.isSet(QStringLiteral("line"))) {
line = m_args.value(QStringLiteral("line")).toInt() - 1;
nav = true;
}
if (m_args.isSet(QStringLiteral("column"))) {
column = m_args.value(QStringLiteral("column")).toInt() - 1;
nav = true;
}
if (nav && activeKateMainWindow()->viewManager()->activeView()) {
activeKateMainWindow()->viewManager()->activeView()->setCursorPosition(KTextEditor::Cursor(line, column));
}
activeKateMainWindow()->setAutoSaveSettings();
}
bool KateApp::setCursor(int line, int column)
{
KateMainWindow *mainWindow = activeKateMainWindow();
......
......@@ -391,6 +391,18 @@ private:
*/
KateSessionManager m_sessionManager;
/**
* Checks if --line and/or --column args were provided and attempts
* to set cursor position in the active document accordingly.
*/
void setCursorFromArgs();
private Q_SLOTS:
/**
* Executed when a document from a remote URL has finished loading.
*/
void remoteDocumentLoaded();
#ifdef WITH_KUSERFEEDBACK
/**
* user feedback provider
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment