Skip to content

Commit

Permalink
Fix issue #78: "Match whole word only" broken for CJK text due to com…
Browse files Browse the repository at this point in the history
…mit 04e5a10.
  • Loading branch information
zufuliu committed Oct 24, 2018
1 parent 8e4d7ed commit a54a3cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions scintilla/src/Document.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ bool Document::IsWordStartAt(Sci::Position pos) const noexcept {
const CharClassify::cc ccPos = WordCharacterClass(cePos.character);
const CharacterExtracted cePrev = CharacterBefore(pos);
const CharClassify::cc ccPrev = WordCharacterClass(cePrev.character);
return (ccPos == CharClassify::ccWord || ccPos == CharClassify::ccPunctuation) &&
return (ccPos == CharClassify::ccWord || ccPos == CharClassify::ccPunctuation || ccPos == CharClassify::ccCJK) &&
(ccPos != ccPrev);
}
return true;
Expand All @@ -1833,7 +1833,7 @@ bool Document::IsWordEndAt(Sci::Position pos) const noexcept {
const CharClassify::cc ccPos = WordCharacterClass(cePos.character);
const CharacterExtracted cePrev = CharacterBefore(pos);
const CharClassify::cc ccPrev = WordCharacterClass(cePrev.character);
return (ccPrev == CharClassify::ccWord || ccPrev == CharClassify::ccPunctuation) &&
return (ccPrev == CharClassify::ccWord || ccPrev == CharClassify::ccPunctuation || ccPrev == CharClassify::ccCJK) &&
(ccPrev != ccPos);
}
return true;
Expand Down Expand Up @@ -2373,7 +2373,8 @@ static bool IsASCIIPunctuationCharacter(unsigned int ch) noexcept {
}

bool Document::IsWordPartSeparator(unsigned int ch) const noexcept {
return (WordCharacterClass(ch) == CharClassify::ccWord) && IsASCIIPunctuationCharacter(ch);
const CharClassify::cc cc = WordCharacterClass(ch);
return (cc == CharClassify::ccWord || cc == CharClassify::ccCJK) && IsASCIIPunctuationCharacter(ch);
}

Sci::Position Document::WordPartLeft(Sci::Position pos) const noexcept {
Expand Down
2 changes: 1 addition & 1 deletion src/Edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -5221,7 +5221,7 @@ void EditMarkAll(HWND hwnd, int iMarkOccurrences, BOOL bMarkOccurrencesMatchCase
const unsigned char ch = pszText[iSelStart];
if (dbcs && IsDBCSLeadByteEx(cpEdit, ch)) {
++iSelStart;
} else if (!(ch >= 0x80 || isalnum(ch) || ch == '_')) {
} else if (!(ch >= 0x80 || IsDocWordChar(ch))) {
NP2HeapFree(pszText);
return;
}
Expand Down

0 comments on commit a54a3cd

Please sign in to comment.