diff -ruN uppsrc/ide/EditorTabBar.cpp uppsrc/ide/EditorTabBar.cpp
--- uppsrc/ide/EditorTabBar.cpp	2011-10-06 23:43:02 +0600
+++ uppsrc/ide/EditorTabBar.cpp	2011-10-29 00:18:12 +0600
@@ -69,6 +69,8 @@
 
 void Ide::TabFile()
 {
+	if(!isTabsAction)
+		return;
 	int q = tabs.GetCursor();
 	if(q >= 0)
 		EditFile(tabs.GetFile(q));
diff -ruN uppsrc/ide/ide.h uppsrc/ide/ide.h
--- uppsrc/ide/ide.h	2011-10-26 17:36:54 +0600
+++ uppsrc/ide/ide.h	2011-10-30 10:52:40 +0600
@@ -461,6 +461,8 @@
 	virtual   void   FileSelected();
 	virtual   void   Serialize(Stream& s);
 	virtual   void   FileRename(const String& nm);
+	virtual   void   FileCloseBefore();
+	virtual   void   FileCloseAfter(int cur, int sb);
 	virtual   void   DragAndDrop(Point p, PasteClip& d);
 
 	virtual   void      PutConsole(const char *s);
@@ -539,6 +541,7 @@
 	One<IdeDesigner> designer;
 	AssistEditor     editor;
 	CodeEditor       editor2;
+	bool             isTabsAction;
 	EditorTabBar     tabs;
 	EscValue         macro_api;
 #ifdef PLATFORM_POSIX
diff -ruN uppsrc/ide/idefile.cpp uppsrc/ide/idefile.cpp
--- uppsrc/ide/idefile.cpp	2011-10-06 23:43:02 +0600
+++ uppsrc/ide/idefile.cpp	2011-10-30 11:21:35 +0600
@@ -396,6 +396,28 @@
 	tabs.RenameFile(editfile, nm);
 }
 
+void Ide::FileCloseBefore()
+{
+	int c = tabs.GetCursor();
+	if(c >= 0) {
+		isTabsAction = false;
+		tabs.CloseForce(c);
+	}
+}
+
+void Ide::FileCloseAfter(int cur, int sb)
+{
+	isTabsAction = true;
+	if(filelist.GetCount())
+		WorkspaceWork::FileCloseAfter(cur, sb);
+	else if(tabs.GetCount() == 0) {
+		tabs.Refresh();
+		FlushFile();
+	}
+	else
+		TabFile();
+}
+
 void Ide::EditFile0(const String& path, byte charset, bool astext, const String& headername) {
 	editor.CheckEdited(false);
 	editor.CloseAssist();
diff -ruN uppsrc/ide/idewin.cpp uppsrc/ide/idewin.cpp
--- uppsrc/ide/idewin.cpp	2011-07-31 03:27:01 +0600
+++ uppsrc/ide/idewin.cpp	2011-10-28 20:47:54 +0600
@@ -504,6 +504,7 @@
 
 	editor.topsbbutton.ScrollStyle().NoWantFocus().Show();
 	editor.topsbbutton1.ScrollStyle().NoWantFocus().Show();
+	isTabsAction = true;
 	tabs <<= THISBACK(TabFile);
 //	tabs.WhenCloseRest = THISBACK1(CloseRest, &tabs);
 	editor2.SetFrame(NullFrame());
diff -ruN uppsrc/ide/UppDlg.h uppsrc/ide/UppDlg.h
--- uppsrc/ide/UppDlg.h	2011-10-07 17:52:46 +0600
+++ uppsrc/ide/UppDlg.h	2011-10-30 11:19:08 +0600
@@ -173,6 +173,8 @@
 	virtual void   SyncWorkspace()                    {}
 	virtual void   FileSelected()                     {}
 	virtual void   FileRename(const String& nm)       {}
+	virtual void   FileCloseBefore()                  {}
+	virtual void   FileCloseAfter(int cur, int sb)    { filelist.SetSbPos(sb); filelist.SetCursor(cur); }
 	virtual void   SyncSvnDir(const String& working)  {}
 
 	void   ScanWorkspace();
diff -ruN uppsrc/ide/UppWspc.cpp uppsrc/ide/UppWspc.cpp
--- uppsrc/ide/UppWspc.cpp	2011-10-14 19:15:25 +0600
+++ uppsrc/ide/UppWspc.cpp	2011-10-30 10:49:13 +0600
@@ -586,14 +586,14 @@
 			if(px >= 0 && (c = closed.Find(Sepfo(GetActivePackage(), actual.file[px]))) >= 0)
 				closed.Unlink(c);
 		}
+		FileCloseBefore();
 		actual.file.Remove(fx);
 	}
 	if(separator || IsAux())
 		SaveLoadPackageNS();
 	else
 		SaveLoadPackage();
-	filelist.SetSbPos(s);
-	filelist.SetCursor(i);
+	FileCloseAfter(i, s);
 }
 
 void WorkspaceWork::DelFile()
diff -ruN uppsrc/TabBar/TabBar.cpp uppsrc/TabBar/TabBar.cpp
--- uppsrc/TabBar/TabBar.cpp	2011-02-16 10:12:56 +0600
+++ uppsrc/TabBar/TabBar.cpp	2011-10-29 00:20:05 +0600
@@ -2298,11 +2298,8 @@
 	Repos();
 }
 
-void TabBar::Close(int n)
+void TabBar::CloseForce(int n)
 {
-	if(tabs.GetCount() <= mintabcount)
-		return;
-
 	if(n == active)
 	{
 		int c = FindId(tabs[n].id);
@@ -2332,6 +2329,14 @@
 	}
 }
 
+void TabBar::Close(int n)
+{
+	if(tabs.GetCount() <= mintabcount)
+		return;
+
+	CloseForce(n);
+}
+
 void TabBar::CloseKey(const Value &key)
 {
 	int tabix = FindKey(key);
diff -ruN uppsrc/TabBar/TabBar.h uppsrc/TabBar/TabBar.h
--- uppsrc/TabBar/TabBar.h	2011-02-16 10:12:56 +0600
+++ uppsrc/TabBar/TabBar.h	2011-10-30 08:47:26 +0600
@@ -394,6 +394,7 @@
 	TabBar& AddKey(const Value& key, const Value& value, Image icon = Null, String group = Null, bool make_active = false);
 	TabBar& InsertKey(int ix, const Value& key, const Value& value, Image icon = Null, String group = Null, bool make_active = false);
 	
+	void 	CloseForce(int n);
 	void 	Close(int n);
 	void 	CloseKey(const Value& key);
 	void 	Clear();
