-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from laurentkempe/feature/EnhancedScrollBar2
Feature/enhanced scroll bar2
- Loading branch information
Showing
45 changed files
with
1,881 additions
and
1,374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="2.6.2" targetFramework="net45" /> | ||
<package id="Shouldly" version="1.1.1.1" /> | ||
<package id="NUnit" version="2.6.3" targetFramework="net45" /> | ||
<package id="Shouldly" version="2.1.1" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 118 additions & 119 deletions
237
GitDiffMargin/DiffUpdateBackgroundParser.cs → ...Margin/Core/DiffUpdateBackgroundParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,119 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using GitDiffMargin.Git; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.Text; | ||
using Stopwatch = System.Diagnostics.Stopwatch; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace GitDiffMargin | ||
{ | ||
public class DiffUpdateBackgroundParser : BackgroundParser | ||
{ | ||
private readonly FileSystemWatcher _watcher; | ||
private readonly IGitCommands _commands; | ||
private readonly ITextDocument _textDocument; | ||
private readonly ITextBuffer _documentBuffer; | ||
|
||
public DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService, IGitCommands commands) | ||
: base(textBuffer, taskScheduler, textDocumentFactoryService) | ||
{ | ||
_documentBuffer = documentBuffer; | ||
_commands = commands; | ||
ReparseDelay = TimeSpan.FromMilliseconds(500); | ||
|
||
if (TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out _textDocument)) | ||
{ | ||
if (_commands.IsGitRepository(_textDocument.FilePath)) | ||
{ | ||
_textDocument.FileActionOccurred += OnFileActionOccurred; | ||
|
||
var solutionDirectory = _commands.GetGitRepository(_textDocument.FilePath); | ||
|
||
if (!string.IsNullOrWhiteSpace(solutionDirectory)) | ||
{ | ||
var gitDirectory = Path.Combine(solutionDirectory, ".git"); | ||
_watcher = new FileSystemWatcher(gitDirectory); | ||
_watcher.Changed += HandleFileSystemChanged; | ||
_watcher.Created += HandleFileSystemChanged; | ||
_watcher.Deleted += HandleFileSystemChanged; | ||
_watcher.Renamed += HandleFileSystemChanged; | ||
_watcher.EnableRaisingEvents = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void HandleFileSystemChanged(object sender, FileSystemEventArgs e) | ||
{ | ||
Action action = () => ProcessFileSystemChange(e); | ||
Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); | ||
} | ||
|
||
private void ProcessFileSystemChange(FileSystemEventArgs e) | ||
{ | ||
if (e.ChangeType == WatcherChangeTypes.Changed && Directory.Exists(e.FullPath)) | ||
return; | ||
|
||
if (string.Equals(Path.GetExtension(e.Name), ".lock", StringComparison.OrdinalIgnoreCase)) | ||
return; | ||
|
||
MarkDirty(true); | ||
} | ||
|
||
private void OnFileActionOccurred(object sender, TextDocumentFileActionEventArgs e) | ||
{ | ||
if ((e.FileActionType & FileActionTypes.ContentSavedToDisk) != 0) | ||
{ | ||
MarkDirty(true); | ||
} | ||
} | ||
|
||
public override string Name | ||
{ | ||
get | ||
{ | ||
return "Git Diff Analyzer"; | ||
} | ||
} | ||
|
||
protected override void ReParseImpl() | ||
{ | ||
try | ||
{ | ||
var stopwatch = Stopwatch.StartNew(); | ||
|
||
var snapshot = TextBuffer.CurrentSnapshot; | ||
ITextDocument textDocument; | ||
if (!TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out textDocument)) return; | ||
|
||
var diff = _commands.GetGitDiffFor(textDocument, snapshot); | ||
var result = new DiffParseResultEventArgs(snapshot, stopwatch.Elapsed, diff.ToList()); | ||
OnParseComplete(result); | ||
} | ||
catch (InvalidOperationException) | ||
{ | ||
MarkDirty(true); | ||
throw; | ||
} | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (disposing) | ||
{ | ||
if (_textDocument != null) | ||
{ | ||
_textDocument.FileActionOccurred -= OnFileActionOccurred; | ||
} | ||
if (_watcher != null) | ||
{ | ||
_watcher.Dispose(); | ||
} | ||
} | ||
} | ||
} | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using GitDiffMargin.Git; | ||
using Microsoft.VisualStudio.Text; | ||
|
||
namespace GitDiffMargin.Core | ||
{ | ||
public class DiffUpdateBackgroundParser : BackgroundParser | ||
{ | ||
private readonly FileSystemWatcher _watcher; | ||
private readonly IGitCommands _commands; | ||
private readonly ITextDocument _textDocument; | ||
private readonly ITextBuffer _documentBuffer; | ||
|
||
public DiffUpdateBackgroundParser(ITextBuffer textBuffer, ITextBuffer documentBuffer, TaskScheduler taskScheduler, ITextDocumentFactoryService textDocumentFactoryService, IGitCommands commands) | ||
: base(textBuffer, taskScheduler, textDocumentFactoryService) | ||
{ | ||
_documentBuffer = documentBuffer; | ||
_commands = commands; | ||
ReparseDelay = TimeSpan.FromMilliseconds(500); | ||
|
||
if (TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out _textDocument)) | ||
{ | ||
if (_commands.IsGitRepository(_textDocument.FilePath)) | ||
{ | ||
_textDocument.FileActionOccurred += OnFileActionOccurred; | ||
|
||
var solutionDirectory = _commands.GetGitRepository(_textDocument.FilePath); | ||
|
||
if (!string.IsNullOrWhiteSpace(solutionDirectory)) | ||
{ | ||
var gitDirectory = Path.Combine(solutionDirectory, ".git"); | ||
_watcher = new FileSystemWatcher(gitDirectory); | ||
_watcher.Changed += HandleFileSystemChanged; | ||
_watcher.Created += HandleFileSystemChanged; | ||
_watcher.Deleted += HandleFileSystemChanged; | ||
_watcher.Renamed += HandleFileSystemChanged; | ||
_watcher.EnableRaisingEvents = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void HandleFileSystemChanged(object sender, FileSystemEventArgs e) | ||
{ | ||
Action action = () => ProcessFileSystemChange(e); | ||
Task.Factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); | ||
} | ||
|
||
private void ProcessFileSystemChange(FileSystemEventArgs e) | ||
{ | ||
if (e.ChangeType == WatcherChangeTypes.Changed && Directory.Exists(e.FullPath)) | ||
return; | ||
|
||
if (string.Equals(Path.GetExtension(e.Name), ".lock", StringComparison.OrdinalIgnoreCase)) | ||
return; | ||
|
||
MarkDirty(true); | ||
} | ||
|
||
private void OnFileActionOccurred(object sender, TextDocumentFileActionEventArgs e) | ||
{ | ||
if ((e.FileActionType & FileActionTypes.ContentSavedToDisk) != 0) | ||
{ | ||
MarkDirty(true); | ||
} | ||
} | ||
|
||
public override string Name | ||
{ | ||
get | ||
{ | ||
return "Git Diff Analyzer"; | ||
} | ||
} | ||
|
||
protected override void ReParseImpl() | ||
{ | ||
try | ||
{ | ||
var stopwatch = Stopwatch.StartNew(); | ||
|
||
var snapshot = TextBuffer.CurrentSnapshot; | ||
ITextDocument textDocument; | ||
if (!TextDocumentFactoryService.TryGetTextDocument(_documentBuffer, out textDocument)) return; | ||
|
||
var diff = _commands.GetGitDiffFor(textDocument, snapshot); | ||
var result = new DiffParseResultEventArgs(snapshot, stopwatch.Elapsed, diff.ToList()); | ||
OnParseComplete(result); | ||
} | ||
catch (InvalidOperationException) | ||
{ | ||
MarkDirty(true); | ||
throw; | ||
} | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (disposing) | ||
{ | ||
if (_textDocument != null) | ||
{ | ||
_textDocument.FileActionOccurred -= OnFileActionOccurred; | ||
} | ||
if (_watcher != null) | ||
{ | ||
_watcher.Dispose(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
using System.Windows.Media; | ||
using GitDiffMargin.Git; | ||
using Microsoft.VisualStudio.Text; | ||
|
||
namespace GitDiffMargin.Core | ||
{ | ||
internal interface IMarginCore | ||
{ | ||
event EventHandler BrushesChanged; | ||
|
||
event EventHandler<IEnumerable<HunkRangeInfo>> HunksChanged; | ||
|
||
GitCommands GitCommands { get; } | ||
FontFamily FontFamily { get; } | ||
FontStretch FontStretch { get; } | ||
FontStyle FontStyle { get; } | ||
FontWeight FontWeight { get; } | ||
double FontSize { get; } | ||
Brush Background { get; } | ||
Brush Foreground { get; } | ||
Brush AdditionBrush { get; } | ||
Brush ModificationBrush { get; } | ||
Brush RemovedBrush { get; } | ||
double EditorChangeLeft { get; } | ||
double EditorChangeWidth { get; } | ||
double ScrollChangeWidth { get; } | ||
void MoveToChange(int lineNumber); | ||
bool RollBack(HunkRangeInfo hunkRangeInfo); | ||
ITextDocument GetTextDocument(); | ||
} | ||
} |
Oops, something went wrong.