Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
[Git] Reload files when they are reverted
Browse files Browse the repository at this point in the history
Add back original code that reloaded reverted files that were open
in the text editor. Without this change if the file is dirty then
the file will not be reloaded and instead the text editor will
show a message about the file being changed outside the IDE. Since
the user explicitly asked to revert the file then the file should
be reloaded automatically even if there are unsaved changes.
  • Loading branch information
mrward committed Jun 13, 2018
1 parent 98a2508 commit a3d9526
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ bool RefreshFile (string path, CheckoutNotifyFlags flags)
{
FilePath fp = RootRepository.FromGitPath (path);
Gtk.Application.Invoke ((o, args) => {
if (IdeApp.IsInitialized) {
MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.GetDocument (fp);
if (doc != null)
doc.Reload ();
}
VersionControlService.NotifyFileStatusChanged (new FileUpdateEventArgs (this, fp, false));
});
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ protected override void Run ()
list[0].Repository.Revert (list.Paths, true, Monitor);

Gtk.Application.Invoke ((o, args) => {
foreach (VersionControlItem item in items) {
if (!item.IsDirectory) {
// Reload reverted files
Document doc = IdeApp.Workbench.GetDocument (item.Path);
if (doc != null && System.IO.File.Exists (item.Path))
doc.Reload ();
}
}
VersionControlService.NotifyFileStatusChanged (items);
});
Monitor.ReportSuccess (GettextCatalog.GetString ("Revert operation completed."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ protected override void Run ()

Gtk.Application.Invoke ((o, args) => {
if (!isDir) {
// Reload reverted files
Document doc = IdeApp.Workbench.GetDocument (path);
if (doc != null)
doc.Reload ();
VersionControlService.NotifyFileStatusChanged (new FileUpdateEventArgs (vc, path, false));
} else {
VersionControlService.NotifyFileStatusChanged (new FileUpdateEventArgs (vc, path, true));
Expand Down

0 comments on commit a3d9526

Please sign in to comment.