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
363b5a68
Commit
363b5a68
authored
Mar 09, 2022
by
Waqar Ahmed
Browse files
Fix LSPHover, honor markup kind
parent
d8cf6287
Pipeline
#147597
passed with stage
in 3 minutes and 38 seconds
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
addons/lspclient/lspclienthover.cpp
View file @
363b5a68
...
...
@@ -71,8 +71,10 @@ public:
}
// combine contents elements to one string
LSPMarkupKind
kind
=
LSPMarkupKind
::
PlainText
;
QString
finalTooltip
;
for
(
auto
&
element
:
info
.
contents
)
{
kind
=
element
.
kind
;
if
(
!
finalTooltip
.
isEmpty
())
{
finalTooltip
.
append
(
QLatin1Char
(
'\n'
));
}
...
...
@@ -81,7 +83,7 @@ public:
// make sure there is no selection, otherwise we interrupt
if
(
!
v
->
selection
())
{
LspTooltip
::
show
(
finalTooltip
,
v
->
mapToGlobal
(
v
->
cursorToCoordinate
(
position
)),
v
,
manual
);
LspTooltip
::
show
(
finalTooltip
,
kind
,
v
->
mapToGlobal
(
v
->
cursorToCoordinate
(
position
)),
v
,
manual
);
}
};
...
...
addons/lspclient/lspclientserver.cpp
View file @
363b5a68
...
...
@@ -510,24 +510,7 @@ static QList<LSPDocumentHighlight> parseDocumentHighlightList(const QJsonValue &
static
LSPMarkupContent
parseHoverContentElement
(
const
QJsonValue
&
contents
)
{
LSPMarkupContent
result
;
if
(
contents
.
isString
())
{
result
.
value
=
contents
.
toString
();
}
else
{
// should be object, pretend so
auto
cont
=
contents
.
toObject
();
auto
text
=
cont
.
value
(
QStringLiteral
(
"value"
)).
toString
();
if
(
text
.
isEmpty
())
{
// nothing to lose, try markdown
result
=
parseMarkupContent
(
contents
);
}
else
{
result
.
value
=
text
;
}
}
if
(
result
.
value
.
length
())
{
result
.
kind
=
LSPMarkupKind
::
PlainText
;
}
return
result
;
return
parseMarkupContent
(
contents
);
}
static
LSPHover
parseHover
(
const
QJsonValue
&
result
)
...
...
addons/lspclient/lsptooltip.cpp
View file @
363b5a68
...
...
@@ -33,15 +33,19 @@ class Tooltip : public QTextBrowser
Q_OBJECT
public:
void
setTooltipText
(
const
QString
&
text
)
void
setTooltipText
(
const
QString
&
text
,
LSPMarkupKind
kind
)
{
if
(
text
.
isEmpty
())
return
;
QString
htext
=
text
;
// we have to do this to handle soft line
htext
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\n
"
));
setMarkdown
(
htext
);
if
(
kind
==
LSPMarkupKind
::
PlainText
)
{
setPlainText
(
text
);
}
else
{
QString
htext
=
text
;
htext
.
replace
(
QLatin1Char
(
'\n'
),
QStringLiteral
(
"
\n
"
));
setMarkdown
(
htext
);
}
resizeTip
(
text
);
}
...
...
@@ -238,7 +242,7 @@ private:
bool
m_manual
;
};
void
LspTooltip
::
show
(
const
QString
&
text
,
QPoint
pos
,
KTextEditor
::
View
*
v
,
bool
manual
)
void
LspTooltip
::
show
(
const
QString
&
text
,
LSPMarkupKind
kind
,
QPoint
pos
,
KTextEditor
::
View
*
v
,
bool
manual
)
{
if
(
text
.
isEmpty
())
return
;
...
...
@@ -252,7 +256,7 @@ void LspTooltip::show(const QString &text, QPoint pos, KTextEditor::View *v, boo
tooltip
=
new
Tooltip
(
v
,
manual
);
tooltip
->
setView
(
v
);
tooltip
->
setTooltipText
(
text
);
tooltip
->
setTooltipText
(
text
,
kind
);
tooltip
->
place
(
pos
);
tooltip
->
show
();
}
...
...
addons/lspclient/lsptooltip.h
View file @
363b5a68
...
...
@@ -6,6 +6,8 @@
#ifndef LSPTOOLTIP_H
#define LSPTOOLTIP_H
#include "lspclientprotocol.h"
#include <QPoint>
class
QWidget
;
...
...
@@ -21,7 +23,7 @@ class LspTooltip
{
public:
// tooltip hidden after timeout msec (if > 0)
static
void
show
(
const
QString
&
text
,
QPoint
pos
,
KTextEditor
::
View
*
v
,
bool
manual
);
static
void
show
(
const
QString
&
text
,
LSPMarkupKind
kind
,
QPoint
pos
,
KTextEditor
::
View
*
v
,
bool
manual
);
};
#endif // LSPTOOLTIP_H
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