From 4978fe7753206a4e4bcd4e7ea6df61e57d01929a Mon Sep 17 00:00:00 2001
From: Michal Jurosz <mj@mj41.cz>
Date: Sat, 11 Aug 2012 21:23:49 +0200
Subject: [PATCH 4/4] Fix recreation of files deleted by process outside of
 Padre.

---
 Padre/lib/Padre/Wx/Main.pm |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/Padre/lib/Padre/Wx/Main.pm b/Padre/lib/Padre/Wx/Main.pm
index fb68314..36c1bf2 100644
--- a/Padre/lib/Padre/Wx/Main.pm
+++ b/Padre/lib/Padre/Wx/Main.pm
@@ -4584,7 +4584,15 @@ sub reload_editor {
 	my $self     = shift;
 	my $editor   = shift || $self->current->editor or return 0;
 	my $document = $editor->document or return 0;
-	my $lock     = $editor->lock_update;
+
+	# If file doesn't exist close the tab
+	unless ( -e $document->{filename} ) {
+		my $id = $self->editor_of_file( $document->{filename} );
+		$self->delete($id);
+		return 1;
+	}
+
+	my $lock = $editor->lock_update;
 
 	# Capture where we are in the document
 	my $line = $editor->LineFromPosition( $editor->GetCurrentPos );
-- 
1.7.7.6

