Skip to content

Commit

Permalink
More accurate word detection and text selection
Browse files Browse the repository at this point in the history
Bump crengine.
Added fix for a correct display of old (before this crengine mod)
saved highlights that included punctuation at edges.
  • Loading branch information
poire-z authored and houqp committed Apr 2, 2017
1 parent 9fcecd2 commit 8396c9e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 17 additions & 2 deletions cre.cpp
Expand Up @@ -1078,10 +1078,25 @@ static int getWordBoxesFromPositions(lua_State *L) {
return 0;
r.sort();

// Old saved highlights may have included punctuation at
// edges (they were not displayed in boxes because of
// lvtinydom.cpp's ldomWordsCollector catching only letters)
// and punctuation was considered part of the word
// (a space was the sole word separator), so
// r.getStart().isVisibleWordStart() and r.getEnd().isVisibleWordEnd()
// were always true.
// With our changes to word detection, this is no more true,
// and the next tests would gather the previous or following
// words, which were not part of the saved highlight !
// But we can change the method to indeed get the word just
// after or before the punctuation and actually get
// exactly the included words without punctuation
if (!r.getStart().isVisibleWordStart())
r.getStart().prevVisibleWordStart();
// r.getStart().prevVisibleWordStart();
r.getStart().nextVisibleWordStart();
if (!r.getEnd().isVisibleWordEnd())
r.getEnd().nextVisibleWordEnd();
// r.getEnd().nextVisibleWordEnd();
r.getEnd().prevVisibleWordEnd();
if (r.isNull())
return 0;

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/kpvcrlib/crengine
Submodule crengine updated 1 files
+63 −14 crengine/src/lvtinydom.cpp

0 comments on commit 8396c9e

Please sign in to comment.