- fix: only highlight fully selected word

This commit is contained in:
royqh1979 2021-08-31 14:41:48 +08:00
parent 72b8d51092
commit acbb7c06b8
3 changed files with 8 additions and 4 deletions

View File

@ -222,6 +222,8 @@ private:
QString mCurrentWord;
QString mCurrentDebugTipWord;
TipType mCurrentTipType;
QString mOldSelectionWord;
QString mSelectionWord;
// QWidget interface
protected:

View File

@ -122,4 +122,6 @@ int StrRScanForNonWordChar(const QString& s, int startPos);
void ensureNotAfter(BufferCoord& cord1, BufferCoord& cord2);
bool isWordChar(const QChar& ch);
#endif // MISCPROCS_H

View File

@ -1221,9 +1221,9 @@ BufferCoord SynEdit::WordStartEx(const BufferCoord &XY)
// valid line?
if ((CY >= 1) && (CY <= mLines->count())) {
QString Line = mLines->getString(CY - 1);
CX = std::min(CX, Line.length());
if (CX-1 >= 0) {
if (!(Line[CX - 1].isSpace()))
CX = std::min(CX, Line.length()+1);
if (CX > 1) {
if (isWordChar(Line[CX - 1]))
CX = StrRScanForNonWordChar(Line, CX - 1) + 1;
else
CX = StrRScanForWordChar(Line, CX - 1) + 1;
@ -1245,7 +1245,7 @@ BufferCoord SynEdit::WordEndEx(const BufferCoord &XY)
if ((CY >= 1) && (CY <= mLines->count())) {
QString Line = mLines->getString(CY - 1);
if (CX <= Line.length()) {
if (!(Line[CX - 1].isSpace()))
if (isWordChar(Line[CX - 2]))
CX = StrScanForNonWordChar(Line, CX);
else
CX = StrScanForWordChar(Line, CX);