mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
Editor: fix completion
This commit is contained in:
parent
bc711e755c
commit
f7589983b5
@ -925,10 +925,10 @@ void VEditUtils::findCurrentWord(QTextCursor p_cursor,
|
|||||||
QString text = p_cursor.block().text();
|
QString text = p_cursor.block().text();
|
||||||
int pib = p_cursor.positionInBlock();
|
int pib = p_cursor.positionInBlock();
|
||||||
|
|
||||||
if (pib < text.size() && text[pib].isSpace()) {
|
if (pib < text.size() && isSpaceOrWordSeparator(text[pib])) {
|
||||||
if (!p_findPrecedingWord
|
if (!p_findPrecedingWord
|
||||||
|| pib == 0
|
|| pib == 0
|
||||||
|| text[pib - 1].isSpace()) {
|
|| isSpaceOrWordSeparator(text[pib - 1])) {
|
||||||
p_start = p_end = p_cursor.position();
|
p_start = p_end = p_cursor.position();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1099,3 +1099,8 @@ QString VEditUtils::removeCodeBlockFence(const QString &p_text)
|
|||||||
int idx = text.indexOf('\n') + 1;
|
int idx = text.indexOf('\n') + 1;
|
||||||
return text.mid(idx, text.size() - idx - 3);
|
return text.mid(idx, text.size() - idx - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VEditUtils::isSpaceOrWordSeparator(QChar p_char)
|
||||||
|
{
|
||||||
|
return p_char.isSpace() || isWordSeparator(p_char);
|
||||||
|
}
|
||||||
|
@ -212,6 +212,8 @@ public:
|
|||||||
|
|
||||||
static bool isWordSeparator(QChar p_char);
|
static bool isWordSeparator(QChar p_char);
|
||||||
|
|
||||||
|
static bool isSpaceOrWordSeparator(QChar p_char);
|
||||||
|
|
||||||
// Remove the fence of fenced code block.
|
// Remove the fence of fenced code block.
|
||||||
static QString removeCodeBlockFence(const QString &p_text);
|
static QString removeCodeBlockFence(const QString &p_text);
|
||||||
|
|
||||||
|
@ -1553,7 +1553,7 @@ QString VEditor::fetchCompletionPrefix() const
|
|||||||
QString prefix;
|
QString prefix;
|
||||||
while (pos >= blockPos) {
|
while (pos >= blockPos) {
|
||||||
QChar ch = m_document->characterAt(pos);
|
QChar ch = m_document->characterAt(pos);
|
||||||
if (ch.isSpace() || VEditUtils::isWordSeparator(ch)) {
|
if (VEditUtils::isSpaceOrWordSeparator(ch)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user