/// <summary>
            /// Prefetch the lsruns up to the point of the specified line length and map
            /// the specified length to the corresponding LSCP length.
            /// </summary>
            /// <remarks>
            /// See comment in the remark section of FullTextState.GetBreakpointInternalCp.
            /// </remarks>
            private int PrefetchLSRuns(
                TextStore   store,
                int         cpFirst,
                int         lineLength
                )
            {
                Debug.Assert(lineLength > 0);

                LSRun lsrun;
                int prefetchLength = 0;
                int lscpLineLength = 0;

                int lastSpanLength = 0;
                int lastRunLength = 0;

                do
                {
                    Plsrun plsrun;
                    int lsrunOffset;
                    int lsrunLength;

                    lsrun = store.FetchLSRun(
                        cpFirst + lscpLineLength,
                        _textFormattingMode,
                        false,
                        out plsrun,
                        out lsrunOffset,
                        out lsrunLength
                        );

                    if (lineLength == prefetchLength && lsrun.Type == Plsrun.Reverse)
                    {
                        break;
                    }

                    lastSpanLength = lsrunLength;
                    lastRunLength = lsrun.Length;

                    lscpLineLength += lastSpanLength;
                    prefetchLength += lastRunLength;

                } while (   !TextStore.IsNewline(lsrun.Type)
                        &&  lineLength >= prefetchLength
                    );

                // calibrate the LSCP length to the LSCP equivalence of the last CP of the line

                if (prefetchLength == lineLength || lastSpanLength == lastRunLength)
                    return lscpLineLength - prefetchLength + lineLength;

                Invariant.Assert(prefetchLength - lineLength == lastRunLength);
                return lscpLineLength - lastSpanLength;
            }