Commit 8224b6fd authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

lspclient: refactor goto location

parent fd6201e3
...@@ -1039,22 +1039,19 @@ public: ...@@ -1039,22 +1039,19 @@ public:
KTextEditor::Document *document = activeView->document(); KTextEditor::Document *document = activeView->document();
KTextEditor::Cursor cdef(line, column); KTextEditor::Cursor cdef(line, column);
KTextEditor::View *targetView = nullptr;
if (document && uri == document->url()) { if (document && uri == document->url()) {
targetView = activeView;
} else {
targetView = m_mainWindow->openUrl(uri);
}
if (targetView) {
// save current position for location history // save current position for location history
Q_EMIT addPositionToHistory(activeView->document()->url(), activeView->cursorPosition()); Q_EMIT addPositionToHistory(activeView->document()->url(), activeView->cursorPosition());
// save the position to which we are jumping in location history // save the position to which we are jumping in location history
Q_EMIT addPositionToHistory(activeView->document()->url(), cdef); Q_EMIT addPositionToHistory(targetView->document()->url(), cdef);
targetView->setCursorPosition(cdef);
activeView->setCursorPosition(cdef); highlightLandingLocation(targetView, location);
highlightLandingLocation(activeView, location);
} else {
KTextEditor::View *view = m_mainWindow->openUrl(uri);
if (view) {
Q_EMIT addPositionToHistory(activeView->document()->url(), activeView->cursorPosition());
Q_EMIT addPositionToHistory(view->document()->url(), cdef);
view->setCursorPosition(cdef);
highlightLandingLocation(view, location);
}
} }
} }
......
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