Commit 2920db3e authored by csillag's avatar csillag

Fix problem with non-integer character positions

 * Updated dom-text-matcher to dd5d2eaf (master branch)
 * Updated Annotators' FuzzyTextAnchors plugin
   to e2e98dd8 (typed-packaging branch)

Fixes #941.
parent 9588a55e
......@@ -89,7 +89,7 @@ class Annotator.Plugin.FuzzyTextAnchors extends Annotator.Plugin
len = @annotator.domMapper.getCorpus().length
# If we don't have the position saved, start at the middle of the doc
expectedStart ?= len / 2
expectedStart ?= Math.floor(len / 2)
# Do the fuzzy search
options =
......
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-e218890
** Annotator 1.2.6-dev-eabb32a
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-11-22 22:31:21Z
** Built at: 2013-11-26 12:46:19Z
*/
......@@ -94,7 +94,7 @@
expectedStart = posSelector != null ? posSelector.start : void 0;
len = this.annotator.domMapper.getCorpus().length;
if (expectedStart == null) {
expectedStart = len / 2;
expectedStart = Math.floor(len / 2);
}
options = {
matchDistance: len * 2,
......
{"version":3,"file":"annotator.fuzzytextanchors.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/fuzzytextanchors.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACCA;CAAA,GAAA,EAAA;KAAA;;oSAAA;;CAAA,CAAM,IAAgB,GAAP;CAEb;;;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEE,SAAA,EAAA;AAAO,CAAP,GAAA,EAAA,CAAyB,EAAR,EAAjB;CACE,aAAM,0DAAN;QADF;AAEO,CAAP,GAAA,EAAA,CAAyB,EAAR,IAAjB;CACE,aAAM,4DAAN;QAHF;CAAA,EAMkB,CAAjB,EAAD,GAAiC,CAAjC,IAAkB;CAAmB,IAAA,IAAS,MAAV;CAAlB,MAAe;CANjC,GASC,EA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,GAAA,WAAO;QAJ1B;AAQA,CAAA,CAAA,EAAA,CAAmB,CAAnB;CAAA,aAAA;QARA;CAAA,CAWuD,CAAzC,CAAC,EAAf,EAAc,CAAU,EAAxB,CAAc,UAAA;CAXd,EAYgB,GAAhB,KAA2B,EAA3B;CAZA,EAeA,CAAO,EAAP,GAAgB;;GAGC,KAAjB;QAlBA;CAAA,EAsBE,GADF,CAAA;CACE,CAAe,CAAA,KAAf,KAAA;CAAA,CACqB,EADrB,IACA,WAAA;CAvBF,OAAA;CAAA,CAwBwC,CAA/B,CAAC,CAAD,CAAT,CAAS,GAAW,CAAX,EAAA;AAGF,CAAP,GAAA,EAAA,CAAqB;CAEnB,GAAA,WAAO;QA7BT;CAAA,EAgCQ,EAAR,CAAA,CAAuB;AAWd,CALJ,CAAyC,CAA1C,CAAA,CACG,CADH,EAKF,CALY,CAAV,GAAA,EAMF,GANE;CA5GN,IAoEe;;CApEf;;CAF8C,QAAS;CAAzD"}
\ No newline at end of file
{"version":3,"file":"annotator.fuzzytextanchors.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/fuzzytextanchors.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACCA;CAAA,GAAA,EAAA;KAAA;;oSAAA;;CAAA,CAAM,IAAgB,GAAP;CAEb;;;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEE,SAAA,EAAA;AAAO,CAAP,GAAA,EAAA,CAAyB,EAAR,EAAjB;CACE,aAAM,0DAAN;QADF;AAEO,CAAP,GAAA,EAAA,CAAyB,EAAR,IAAjB;CACE,aAAM,4DAAN;QAHF;CAAA,EAMkB,CAAjB,EAAD,GAAiC,CAAjC,IAAkB;CAAmB,IAAA,IAAS,MAAV;CAAlB,MAAe;CANjC,GASC,EAAD,GAAU,UAAoB;CAI5B,CAAM,EAAN,IAAA,SAAA;CAAA,CACM,EAAN,IAAA,aADA;CAbF,OASA;CAOC,GAAA,KAAS,IAAV,MAA8B;CA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,EAAxB,CAAc,UAAA;CAXd,EAYgB,GAAhB,KAA2B,EAA3B;CAZA,EAeA,CAAO,EAAP,GAAgB;;CAGM,EAAL,CAAI,CAAJ,GAAjB;QAlBA;CAAA,EAsBE,GADF,CAAA;CACE,CAAe,CAAA,KAAf,KAAA;CAAA,CACqB,EADrB,IACA,WAAA;CAvBF,OAAA;CAAA,CAwBwC,CAA/B,CAAC,CAAD,CAAT,CAAS,GAAW,CAAX,EAAA;AAGF,CAAP,GAAA,EAAA,CAAqB;CAEnB,GAAA,WAAO;QA7BT;CAAA,EAgCQ,EAAR,CAAA,CAAuB;AAWd,CALJ,CAAyC,CAA1C,CAAA,CACG,CADH,EAKF,CALY,CAAV,GAAA,EAMF,GANE;CA5GN,IAoEe;;CApEf;;CAF8C,QAAS;CAAzD"}
\ No newline at end of file
......@@ -72,7 +72,7 @@ class window.DomTextMatcher
expectedPrefixStart = if expectedStart?
expectedStart - prefix.length
else
len / 2
Math.floor(len / 2)
# Do the fuzzy search for the prefix
@dmp.setMatchDistance options.contextMatchDistance ? len * 2
......
......@@ -106,7 +106,10 @@ class window.DTM_DMPMatcher
# console.log "In dtm search. text: '" + text + "', pattern: '" + pattern +
# "', expectedStartLoc: " + expectedStartLoc + ", options:"
# console.log options
if expectedStartLoc < 0 then throw new Error "Can't search at negative indices!"
if expectedStartLoc < 0
throw new Error "Can't search at negative indices!"
if expectedStartLoc isnt Math.floor expectedStartLoc
throw new Error "Expected start location must be an integer."
unless @caseSensitive
text = text.toLowerCase()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment