Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
18be604f
Commit
18be604f
authored
May 05, 2021
by
Mark Nauwelaerts
Browse files
lspclient: reduce view scroll upon diagnostics update
parent
7ea264d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclientpluginview.cpp
View file @
18be604f
...
...
@@ -2142,6 +2142,8 @@ public:
QStandardItemModel
*
model
=
m_diagnosticsModel
.
data
();
QStandardItem
*
topItem
=
getItem
(
*
m_diagnosticsModel
,
diagnostics
.
uri
);
// current diagnostics row, if one of incoming diagnostics' document
int
row
=
-
1
;
if
(
!
topItem
)
{
// no need to create an empty one
if
(
diagnostics
.
diagnostics
.
empty
())
{
...
...
@@ -2151,6 +2153,11 @@ public:
model
->
appendRow
(
topItem
);
topItem
->
setText
(
diagnostics
.
uri
.
toLocalFile
());
}
else
{
// try to retain current position
auto
currentIndex
=
m_diagnosticsTree
->
currentIndex
();
if
(
currentIndex
.
parent
()
==
topItem
->
index
())
{
row
=
currentIndex
.
row
();
}
topItem
->
setRowCount
(
0
);
}
...
...
@@ -2184,13 +2191,17 @@ public:
// and only the whole text when item selected ??
m_diagnosticsTree
->
setExpanded
(
topItem
->
index
(),
true
);
m_diagnosticsTree
->
setRowHidden
(
topItem
->
row
(),
QModelIndex
(),
topItem
->
rowCount
()
==
0
);
m_diagnosticsTree
->
scrollTo
(
topItem
->
index
(),
QAbstractItemView
::
PositionAtTop
);
updateMarks
();
// also sync updated diagnos
i
tic to current position
// also sync updated diagnostic to current position
auto
currentView
=
m_mainWindow
->
activeView
();
if
(
currentView
&&
currentView
->
document
())
{
syncDiagnostics
(
currentView
->
document
(),
currentView
->
cursorPosition
().
line
(),
false
,
false
);
if
(
!
syncDiagnostics
(
currentView
->
document
(),
currentView
->
cursorPosition
().
line
(),
false
,
false
))
{
// avoid jitter; only restore previous if applicable
if
(
row
>=
0
&&
row
<
topItem
->
rowCount
())
{
m_diagnosticsTree
->
scrollTo
(
topItem
->
child
(
row
)
->
index
());
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment