public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, ITextSnapshot snapshot)
        {
            string fileName = textDocument.FilePath;
            GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(fileName));
            if (!tracker.HasGitRepository || tracker.Repository.Resolve(Constants.HEAD) == null)
                yield break;

            GitFileStatus status = tracker.GetFileStatus(fileName);
            if (status == GitFileStatus.New || status == GitFileStatus.Added)
                yield break;

            HistogramDiff diff = new HistogramDiff();
            diff.SetFallbackAlgorithm(null);
            string currentText = snapshot.GetText();

            byte[] preamble = textDocument.Encoding.GetPreamble();
            byte[] content = textDocument.Encoding.GetBytes(currentText);
            if (preamble.Length > 0)
            {
                byte[] completeContent = new byte[preamble.Length + content.Length];
                Buffer.BlockCopy(preamble, 0, completeContent, 0, preamble.Length);
                Buffer.BlockCopy(content, 0, completeContent, preamble.Length, content.Length);
                content = completeContent;
            }

            byte[] previousContent = GetPreviousRevision(tracker, fileName);
            RawText b = new RawText(content);
            RawText a = new RawText(previousContent);
            EditList edits = diff.Diff(RawTextComparator.DEFAULT, a, b);
            foreach (Edit edit in edits)
                yield return new HunkRangeInfo(snapshot, edit, a, b);
        }
示例#2
0
        public IEnumerable <HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, ITextSnapshot snapshot)
        {
            string fileName = textDocument.FilePath;
            GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(fileName));

            if (!tracker.HasGitRepository || tracker.Repository.Resolve(Constants.HEAD) == null)
            {
                yield break;
            }

            GitFileStatus status = tracker.GetFileStatus(fileName);

            if (status == GitFileStatus.New || status == GitFileStatus.Added)
            {
                yield break;
            }

            HistogramDiff diff = new HistogramDiff();

            diff.SetFallbackAlgorithm(null);
            string currentText = snapshot.GetText();

            byte[] preamble = textDocument.Encoding.GetPreamble();
            byte[] content  = textDocument.Encoding.GetBytes(currentText);
            if (preamble.Length > 0)
            {
                byte[] completeContent = new byte[preamble.Length + content.Length];
                Buffer.BlockCopy(preamble, 0, completeContent, 0, preamble.Length);
                Buffer.BlockCopy(content, 0, completeContent, preamble.Length, content.Length);
                content = completeContent;
            }

            byte[]   previousContent = GetPreviousRevision(tracker, fileName);
            RawText  b     = new RawText(content);
            RawText  a     = new RawText(previousContent ?? new byte[0]);
            EditList edits = diff.Diff(RawTextComparator.DEFAULT, a, b);

            foreach (Edit edit in edits)
            {
                yield return(new HunkRangeInfo(snapshot, edit, a, b));
            }
        }
 public SnapshotTokenFactory(ITextSnapshot snapshot, Tuple<ITokenSource, ICharStream> effectiveSource)
 {
     this.snapshot = snapshot;
     this.effectiveSource = effectiveSource;
 }
 public SnapshotTokenFactory(ITextSnapshot snapshot, ITokenSource effectiveSource)
 {
     this.snapshot = snapshot;
     this.effectiveSource = Tuple.Create(effectiveSource, effectiveSource.InputStream);
 }
示例#5
0
 public ShimTextBufferAdapter(Microsoft.VisualStudio.Text.ITextSnapshot snapshot)
 {
     Snapshot   = snapshot;
     _cachedPos = -1;
 }
示例#6
0
 public Microsoft.VisualStudio.Text.SnapshotPoint?GetTriggerPoint(Microsoft.VisualStudio.Text.ITextSnapshot textSnapshot)
 {
     throw new NotImplementedException();
 }
 public SnapshotTokenFactory(ITextSnapshot snapshot, Tuple <ITokenSource, ICharStream> effectiveSource)
 {
     this.snapshot        = snapshot;
     this.effectiveSource = effectiveSource;
 }
 public SnapshotTokenFactory(ITextSnapshot snapshot, ITokenSource effectiveSource)
 {
     this.snapshot        = snapshot;
     this.effectiveSource = Tuple.Create(effectiveSource, effectiveSource.InputStream);
 }
示例#9
0
 public CaretLocationEventArgs(DocumentLocation location, Microsoft.VisualStudio.Text.ITextSnapshot textSnapshot, CaretChangeReason reason) : base(location)
 {
     Snapshot          = textSnapshot;
     CaretChangeReason = reason;
 }
示例#10
0
 public SnapshotToken(int type, string text)
     : base(type, text)
 {
     snapshot = null;
 }
示例#11
0
 public SnapshotToken(ITextSnapshot snapshot, Tuple <ITokenSource, ICharStream> source, int type, int channel, int start, int stop)
     : base(source, type, channel, start, stop)
 {
     this.snapshot = snapshot;
 }
 public SnapshotToken(int type, string text)
     : base(type, text)
 {
     snapshot = null;
 }
 public SnapshotToken(ITextSnapshot snapshot, Tuple<ITokenSource, ICharStream> source, int type, int channel, int start, int stop)
     : base(source, type, channel, start, stop)
 {
     this.snapshot = snapshot;
 }