ARCed.Scintilla.SnippetManager.cascadeSnippetLinkRangeChange C# (CSharp) Method

cascadeSnippetLinkRangeChange() private method

private cascadeSnippetLinkRangeChange ( SnippetLink oldActiveSnippetLink, SnippetLinkRange oldActiveRange ) : void
oldActiveSnippetLink SnippetLink
oldActiveRange SnippetLinkRange
return void
        private void cascadeSnippetLinkRangeChange(SnippetLink oldActiveSnippetLink, SnippetLinkRange oldActiveRange)
        {
            Scintilla.ManagedRanges.Sort();

            int offset = 0;

            string newText = oldActiveRange.Text;

            Scintilla.NativeInterface.SetModEventMask(0);
            foreach (ManagedRange mr in Scintilla.ManagedRanges)
            {
                if (offset != 0)
                    mr.Change(mr.Start + offset, mr.End + offset);

                var slr = mr as SnippetLinkRange;
                if (slr == null || !oldActiveSnippetLink.Ranges.Contains(slr) || slr.Text == newText)
                    continue;

                int oldLength = slr.Length;
                slr.Text = newText;
                slr.End += newText.Length - oldLength;
                offset += newText.Length - oldLength;
            }

            Scintilla.NativeInterface.SetModEventMask(Constants.SC_MODEVENTMASKALL);
        }