Commit MetaInfo

Revisionf081ed7ffd4ce6a1280cb3d948851d78b3aec7b0 (tree)
Time2017-10-22 10:52:15
Author <exeal@user...>

Log Message

fixed: kernel.locations.shrinkToDocumentRegion returned an incorrect value.

Change Summary

Incremental Difference

diff -r 38b426a8b495 -r f081ed7ffd4c ascension/src/kernel/locations.cpp
--- a/ascension/src/kernel/locations.cpp Sat Sep 02 23:43:39 2017 +0900
+++ b/ascension/src/kernel/locations.cpp Sun Oct 22 10:52:15 2017 +0900
@@ -7,6 +7,7 @@
77 * @date 2016-05-22 Separated from point.cpp.
88 */
99
10+#include <ascension/corelib/numeric-range-algorithm/clamp.hpp>
1011 #include <ascension/corelib/text/character-property.hpp> // text.ucd.BinaryProperty
1112 #include <ascension/corelib/text/grapheme-break-iterator.hpp>
1213 #include <ascension/corelib/text/word-break-iterator.hpp>
@@ -331,12 +332,7 @@
331332 Position shrinkToAccessibleRegion(const PointProxy& p) BOOST_NOEXCEPT {
332333 if(!document(p).isNarrowed())
333334 return shrinkToDocumentRegion(p);
334- const auto accessibleRegion(document(p).accessibleRegion());
335- if(position(p) < *boost::const_begin(accessibleRegion))
336- return *boost::const_begin(accessibleRegion);
337- else if(position(p) > *boost::const_end(accessibleRegion))
338- return *boost::const_end(accessibleRegion);
339- return Position(line(p), std::min(offsetInLine(p), document(p).lineLength(line(p))));
335+ return clamp(position(p), document(p).accessibleRegion());
340336 }
341337
342338 /**
@@ -357,9 +353,7 @@
357353 * @return The result
358354 */
359355 Position shrinkToDocumentRegion(const PointProxy& p) BOOST_NOEXCEPT {
360- Position q(std::min(line(p), document(p).numberOfLines() - 1), 0);
361- q.offsetInLine = std::min(offsetInLine(q), document(p).lineLength(line(q)));
362- return q;
356+ return std::min(position(p), *boost::const_end(document(p).region()));
363357 }
364358
365359 /**
Show on old repository browser