예제 #1
0
        /// <summary>
        /// Tells document that massive change to text buffer is complete. Document will perform full parse,
        /// resume tracking of text buffer changes and classification (colorization).
        /// </summary>
        /// <returns>True if changes were made to the text buffer since call to BeginMassiveChange</returns>
        public bool EndMassiveChange()
        {
            bool changed = _editorTree.TreeUpdateTask.TextBufferChangedSinceSuspend;

            if (_inMassiveChange == 1)
            {
                RClassifier colorizer = ServiceManager.GetService <RClassifier>(TextBuffer);
                if (colorizer != null)
                {
                    colorizer.Resume();
                }

                if (changed)
                {
                    TextChangeEventArgs textChange = new TextChangeEventArgs(0, 0, TextBuffer.CurrentSnapshot.Length, 0,
                                                                             new TextProvider(_editorTree.TextSnapshot, partial: true), new TextStream(string.Empty));

                    List <TextChangeEventArgs> textChanges = new List <TextChangeEventArgs>();
                    textChanges.Add(textChange);
                    _editorTree.FireOnUpdatesPending(textChanges);

                    _editorTree.FireOnUpdateBegin();
                    _editorTree.FireOnUpdateCompleted(TreeUpdateType.NewTree);
                }

                _editorTree.TreeUpdateTask.Resume();

                if (MassiveChangeEnded != null)
                {
                    MassiveChangeEnded(this, EventArgs.Empty);
                }
            }

            if (_inMassiveChange > 0)
            {
                _inMassiveChange--;
            }

            return(changed);
        }