示例#1
0
        private void PopulateSourceEdits(ITextBuffer buffer)
        {
            IProjectionBufferBase projectionBuffer = buffer as IProjectionBufferBase;

            if (projectionBuffer != null)
            {
                // Add ITextEdit objects to the edit map for all source buffers of the current projection buffer that
                // are themselves projection buffers. This is so that such buffers are not considered independent buffers
                // if it happens that the master edit does not touch them directly (even though not touched directly, they
                // may receive events from their source buffers that were touched directly, and so FinalApply() will need
                // to be invoked on them in order to construct a snapshot that matches the last snapshots of their source buffers).
                foreach (ITextBuffer sourceBuffer in projectionBuffer.SourceBuffers)
                {
                    IProjectionBufferBase sourceProjectionBuffer = sourceBuffer as IProjectionBufferBase;
                    if (sourceProjectionBuffer != null)
                    {
                        BaseBuffer baseSourceBuffer = (BaseBuffer)sourceBuffer;
                        if (!this.buffer2EditMap.ContainsKey(baseSourceBuffer))
                        {
                            this.buffer2EditMap.Add(sourceBuffer, (baseSourceBuffer.CreateSubordinateEdit(this.masterOptions, null, this.masterEditTag)));
                        }
                    }
                }
            }
        }
示例#2
0
        public ITextEdit GetEdit(BaseBuffer buffer, EditOptions options)
        {
            ISubordinateTextEdit subedit;

            if (!this.buffer2EditMap.TryGetValue(buffer, out subedit))
            {
                Debug.Assert(!(buffer is IProjectionBufferBase));
                subedit = buffer.CreateSubordinateEdit(options, null, this.masterEditTag);
                this.buffer2EditMap.Add(buffer, subedit);
            }
            return((ITextEdit)subedit);
        }