Skip to content

Commit

Permalink
Fix a bug in handling the first character of a text box
Browse files Browse the repository at this point in the history
Fixes #605.
  • Loading branch information
birtles committed May 22, 2021
1 parent 179d815 commit 8b5bb60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.6 (not released yet)

- Fixed handling of the first character of a text box
([#605](https://github.com/birtles/rikaichamp/issues/605))

## 0.5.5 (2021-05-11)

- Fixed release infrastructure and tweaked options page.
Expand Down
6 changes: 4 additions & 2 deletions src/get-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export function getTextAtPoint(
node: elemUnderCursor,
point,
});
position = offset ? { offset, offsetNode: elemUnderCursor } : null;
position =
offset !== null ? { offset, offsetNode: elemUnderCursor } : null;
}
}

Expand Down Expand Up @@ -443,7 +444,8 @@ function getTextFromTextNode(
// * U+FF66~U+FF9F is halfwidth katakana
// * U+20000~U+2A6DF is CJK Unified Ideographs Extension B (more rare kanji)
//
const nonJapaneseOrDelimiter = /[^\uff01-\uff5e\u25cb\u3004-\u3007\u3011-\u30ff\u3220-\u3247\u3280-\u32b0\u32d0-\u32ff\u3300-\u3370\u337b-\u337f\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff5e\uff66-\uff9f\u{20000}-\u{2a6df}]/u;
const nonJapaneseOrDelimiter =
/[^\uff01-\uff5e\u25cb\u3004-\u3007\u3011-\u30ff\u3220-\u3247\u3280-\u32b0\u32d0-\u32ff\u3300-\u3370\u337b-\u337f\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff5e\uff66-\uff9f\u{20000}-\u{2a6df}]/u;

// If we detect a Japanese era, however, we allow a different set of
// characters.
Expand Down

0 comments on commit 8b5bb60

Please sign in to comment.