- 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 mCurrentWord;
QString mCurrentDebugTipWord; QString mCurrentDebugTipWord;
TipType mCurrentTipType; TipType mCurrentTipType;
QString mOldSelectionWord;
QString mSelectionWord;
// QWidget interface // QWidget interface
protected: protected:

View File

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

View File

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