Esempio n. 1
0
        protected virtual void OnSubjectBufferChanged(object sender, TextContentChangedEventArgs e)
        {
            if (Session != null && e.Changes.Count > 0)
            {
                int start, oldLength, newLength;
                TextUtility.CombineChanges(e, out start, out oldLength, out newLength);

                int position = start + newLength;
                if (position < _initialPosition)
                {
                    SignatureHelp.DismissSession(TextView);
                }
                else
                {
                    UpdateCurrentParameter();
                }
            }
        }
Esempio n. 2
0
        protected virtual void OnTextChanged(object sender, TextContentChangedEventArgs e)
        {
            int start, oldLength, newLength;

            TextUtility.CombineChanges(e, out start, out oldLength, out newLength);

            // check if change is still within current snapshot. the problem is that
            // change could have been calculated against projected buffer and then
            // host (HTML editor) could have dropped projections effectively
            // shortening buffer to nothing.

            var snapshot = TextBuffer.CurrentSnapshot;

            if (start > snapshot.Length || start + newLength > snapshot.Length)
            {
                start     = 0;
                newLength = snapshot.Length;
            }

            OnTextChanged(start, oldLength, newLength);
        }
Esempio n. 3
0
        protected virtual void OnTextBufferChanged(object sender, TextContentChangedEventArgs e)
        {
            // In order to provide nicer experience when user presser and holds
            // ENTER or DELETE or just types really fast, we are going to track
            // regions optimistically and report changes without going through
            // async or idle processing. Idle/async is still going to hit later.

            if (e.Changes.Count > 0)
            {
                int start, oldLength, newLength;
                TextUtility.CombineChanges(e, out start, out oldLength, out newLength);

                int changeStart = Int32.MaxValue;
                int changeEnd   = 0;

                lock (_regionsLock) {
                    // Remove affected regions and shift the remaining ones. Outlining
                    // regions are not sorted and can overlap. Hence linear search.

                    for (int i = 0; i < CurrentRegions.Count; i++)
                    {
                        var region = CurrentRegions[i];

                        if (region.End <= start)
                        {
                            continue;
                        }

                        if (region.Contains(start) && region.Contains(start + oldLength))
                        {
                            region.Expand(0, newLength - oldLength);
                        }
                        else if (region.Start >= start + oldLength)
                        {
                            region.Shift(newLength - oldLength);
                        }
                        else
                        {
                            changeStart = Math.Min(changeStart, region.Start);
                            changeEnd   = Math.Max(changeEnd, region.End);

                            CurrentRegions.RemoveAt(i);
                            i--;

                            if (e.Changes.Count > 0)
                            {
                                // If we merged changes, this might be an overaggressive delete. Ensure
                                //   that we'll do a full recalculation later.
                                BackgroundTask.DoTaskOnIdle();
                            }
                        }
                    }
                }

                // If there were previously any regions, make sure we notify our listeners of the changes
                if ((CurrentRegions.Count > 0) || (changeStart < Int32.MaxValue))
                {
                    CurrentRegions.TextBufferVersion = TextBuffer.CurrentSnapshot.Version.VersionNumber;
                    if (RegionsChanged != null)
                    {
                        changeEnd = (changeStart == Int32.MaxValue ? changeStart : changeEnd);
                        RegionsChanged(this, new OutlineRegionsChangedEventArgs(CurrentRegions, TextRange.FromBounds(changeStart, changeEnd)));
                    }
                }
            }
        }