Skip to content

Commit

Permalink
Fix Document::ExtendWordSelect() broken for CJK word.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 10, 2019
1 parent f8bea1a commit ffec915
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scintilla/src/Document.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1688,9 +1688,15 @@ CharClassify::cc Document::WordCharacterClass(unsigned int ch) const noexcept {
Sci::Position Document::ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters) const noexcept {
CharClassify::cc ccStart = CharClassify::ccWord;
if (delta < 0) {
if (!onlyWordCharacters) {
if (pos > 0) {
const CharacterExtracted ce = CharacterBefore(pos);
ccStart = WordCharacterClass(ce.character);
const CharClassify::cc ceStart = WordCharacterClass(ce.character);
if (!onlyWordCharacters || ceStart == ccStart || ceStart == CharClassify::ccCJKWord) {
ccStart = ceStart;
pos -= ce.widthBytes;
} else {
return MovePositionOutsideChar(pos, delta, true);
}
}
while (pos > 0) {
const CharacterExtracted ce = CharacterBefore(pos);
Expand All @@ -1699,9 +1705,15 @@ Sci::Position Document::ExtendWordSelect(Sci::Position pos, int delta, bool only
pos -= ce.widthBytes;
}
} else {
if (!onlyWordCharacters && pos < Length()) {
if (pos < Length()) {
const CharacterExtracted ce = CharacterAfter(pos);
ccStart = WordCharacterClass(ce.character);
const CharClassify::cc ceStart = WordCharacterClass(ce.character);
if (!onlyWordCharacters || ceStart == ccStart || ceStart == CharClassify::ccCJKWord) {
ccStart = ceStart;
pos += ce.widthBytes;
} else {
return MovePositionOutsideChar(pos, delta, true);
}
}
while (pos < Length()) {
const CharacterExtracted ce = CharacterAfter(pos);
Expand Down

0 comments on commit ffec915

Please sign in to comment.