Browse Source

bug-fix: respect the open mode even if the file has been opened

Le Tan 8 years ago
parent
commit
73ede805d1
1 changed files with 12 additions and 1 deletions
  1. 12 1
      src/veditarea.cpp

+ 12 - 1
src/veditarea.cpp

@@ -126,10 +126,10 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
     if (!p_file) {
         return;
     }
-    qDebug() << "VEditArea open" << p_file->getName() << (int)p_mode;
 
     // Find if it has been opened already
     int winIdx, tabIdx;
+    bool existFile = false;
     bool setFocus = false;
     auto tabs = findTabsByFile(p_file);
     if (!tabs.empty()) {
@@ -143,7 +143,9 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
                 break;
             }
         }
+
         setFocus = true;
+        existFile = true;
         goto out;
     }
 
@@ -153,11 +155,20 @@ void VEditArea::openFile(VFile *p_file, OpenFileMode p_mode)
         insertSplitWindow(0);
         curWindowIndex = 0;
     }
+
     winIdx = curWindowIndex;
     tabIdx = openFileInWindow(winIdx, p_file, p_mode);
 
 out:
     setCurrentTab(winIdx, tabIdx, setFocus);
+
+    if (existFile) {
+        if (p_mode == OpenFileMode::Read) {
+            readFile();
+        } else if (p_mode == OpenFileMode::Edit) {
+            editFile();
+        }
+    }
 }
 
 QVector<QPair<int, int> > VEditArea::findTabsByFile(const VFile *p_file)