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
abbc3f04
Commit
abbc3f04
authored
Jun 07, 2021
by
Waqar Ahmed
Browse files
Use a unique and remove tracking of connected views for vertical scroll
parent
b2aa879e
Changes
3
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclientpluginview.cpp
View file @
abbc3f04
...
...
@@ -509,6 +509,7 @@ public:
,
m_hover
(
LSPClientHover
::
new_
(
m_serverManager
))
,
m_forwardHover
(
new
ForwardingTextHintProvider
(
this
))
,
m_symbolView
(
LSPClientSymbolView
::
new_
(
plugin
,
mainWin
,
m_serverManager
))
,
m_semHighlightingManager
(
m_serverManager
)
{
connect
(
m_mainWindow
,
&
KTextEditor
::
MainWindow
::
viewChanged
,
this
,
&
self_type
::
updateState
);
connect
(
m_mainWindow
,
&
KTextEditor
::
MainWindow
::
unhandledShortcutOverride
,
this
,
&
self_type
::
handleEsc
);
...
...
@@ -2277,7 +2278,7 @@ public:
}
if
(
m_plugin
->
m_semanticHighlighting
)
{
m_semHighlightingManager
.
doSemanticHighlighting
(
activeView
,
m_serverManager
);
m_semHighlightingManager
.
doSemanticHighlighting
(
activeView
);
}
if
(
m_onTypeFormattingTriggers
.
empty
())
{
...
...
@@ -2340,7 +2341,7 @@ public:
const
bool
semHighlightingEnabled
=
m_plugin
->
m_semanticHighlighting
;
if
(
semHighlightingEnabled
)
{
m_semHighlightingManager
.
doSemanticHighlighting
(
activeView
,
m_serverManager
);
m_semHighlightingManager
.
doSemanticHighlighting
(
activeView
);
}
}
...
...
addons/lspclient/lspsemantichighlighting.cpp
View file @
abbc3f04
...
...
@@ -13,8 +13,9 @@
#include <KTextEditor/MovingRange>
#include <KTextEditor/View>
SemanticHighlighter
::
SemanticHighlighter
(
QObject
*
parent
)
SemanticHighlighter
::
SemanticHighlighter
(
QSharedPointer
<
LSPClientServerManager
>
serverManager
,
QObject
*
parent
)
:
QObject
(
parent
)
,
m_serverManager
(
std
::
move
(
serverManager
))
{
}
...
...
@@ -29,13 +30,13 @@ static KTextEditor::Range getCurrentViewLinesRange(KTextEditor::View *view)
return
KTextEditor
::
Range
(
first
,
0
,
last
,
lastLineLen
);
}
void
SemanticHighlighter
::
doSemanticHighlighting
(
KTextEditor
::
View
*
view
,
QSharedPointer
<
LSPClientServerManager
>
serverManager
)
void
SemanticHighlighter
::
doSemanticHighlighting
(
KTextEditor
::
View
*
view
)
{
if
(
!
view
)
{
return
;
}
auto
server
=
serverManager
->
findServer
(
view
);
auto
server
=
m_
serverManager
->
findServer
(
view
);
if
(
!
server
)
{
return
;
}
...
...
@@ -57,24 +58,7 @@ void SemanticHighlighter::doSemanticHighlighting(KTextEditor::View *view, QShare
}
if
(
caps
.
semanticTokenProvider
.
range
)
{
if
(
!
m_docSemanticConnectedViews
.
insert
(
view
).
second
)
{
// track vertical scrolling for this view
QPointer
<
KTextEditor
::
View
>
v
=
view
;
connect
(
view
,
&
KTextEditor
::
View
::
verticalScrollPositionChanged
,
this
,
[
this
,
v
,
serverManager
]()
{
doSemanticHighlighting
(
v
,
serverManager
);
},
Qt
::
UniqueConnection
);
// clean it up from our set after the view is gone
connect
(
view
,
&
KTextEditor
::
View
::
destroyed
,
this
,
[
this
](
QObject
*
o
)
{
auto
view
=
static_cast
<
KTextEditor
::
View
*>
(
o
);
m_docSemanticConnectedViews
.
erase
(
view
);
});
}
connect
(
view
,
&
KTextEditor
::
View
::
verticalScrollPositionChanged
,
this
,
&
SemanticHighlighter
::
semanticHighlightRange
,
Qt
::
UniqueConnection
);
}
// m_semHighlightingManager.setTypes(server->capabilities().semanticTokenProvider.types);
...
...
@@ -97,6 +81,11 @@ void SemanticHighlighter::doSemanticHighlighting(KTextEditor::View *view, QShare
}
}
void
SemanticHighlighter
::
semanticHighlightRange
(
KTextEditor
::
View
*
view
,
const
KTextEditor
::
Cursor
&
)
{
doSemanticHighlighting
(
view
);
}
QString
SemanticHighlighter
::
previousResultIdForDoc
(
KTextEditor
::
Document
*
doc
)
const
{
auto
it
=
m_docResultId
.
find
(
doc
);
...
...
addons/lspclient/lspsemantichighlighting.h
View file @
abbc3f04
...
...
@@ -31,11 +31,13 @@ class SemanticHighlighter : public QObject
{
Q_OBJECT
public:
SemanticHighlighter
(
QObject
*
parent
=
nullptr
);
SemanticHighlighter
(
QSharedPointer
<
LSPClientServerManager
>
serverManager
,
QObject
*
parent
=
nullptr
);
void
doSemanticHighlighting
(
KTextEditor
::
View
*
v
,
QSharedPointer
<
LSPClientServerManager
>
serverManager
);
void
doSemanticHighlighting
(
KTextEditor
::
View
*
v
);
private:
void
semanticHighlightRange
(
KTextEditor
::
View
*
view
,
const
KTextEditor
::
Cursor
&
);
QString
previousResultIdForDoc
(
KTextEditor
::
Document
*
doc
)
const
;
/**
...
...
@@ -84,10 +86,6 @@ private:
*/
std
::
unordered_map
<
KTextEditor
::
Document
*
,
TokensData
>
m_docSemanticInfo
;
/**
* Views whose vertical scroll we are tracking for semantic tokens range request.
* This is important, otherwise performance can get really crappy.
*/
std
::
unordered_set
<
KTextEditor
::
View
*>
m_docSemanticConnectedViews
;
QSharedPointer
<
LSPClientServerManager
>
m_serverManager
;
};
#endif
Write
Preview
Markdown
is supported
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