예제 #1
0
        static bool TryExpandSelection(ref int begin, ref int end, StringSlice line, Func <StringSlice, bool, StringSlice?> testSubstr)
        {
            int begin2 = begin;
            int end2   = end;

            while (begin2 > 0 && testSubstr(line.Slice(begin2 - 1, end2), true) != null)
            {
                --begin2;
            }
            while (end2 <= line.Length - 1 && testSubstr(line.Slice(begin2, end2 + 1), true) != null)
            {
                ++end2;
            }

            var finalStr = testSubstr(line.Slice(begin2, end2), false);

            if (finalStr == null)
            {
                return(false);
            }

            begin = finalStr.Value.StartIndex - line.StartIndex;
            end   = finalStr.Value.EndIndex - line.StartIndex;

            return(true);
        }