]> git.lyx.org Git - features.git/commitdiff
Fix bug #5878: Cursor position not restored in hidden documents.
authorVincent van Ravesteijn <vfr@lyx.org>
Sun, 24 Oct 2010 23:41:15 +0000 (23:41 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 24 Oct 2010 23:41:15 +0000 (23:41 +0000)
A hidden document does not have an associated Cursor. So, each time we create a new workArea, we should restore the cursor position.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35811 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp

index 585c24c49b75a352c26665dc72f58032ae976fac..5d604fca05f88f0f346607c4c493a935e9155dcd 100644 (file)
@@ -1328,6 +1328,12 @@ void GuiView::setBuffer(Buffer * newBuffer)
        if (wa == 0) {
                newBuffer->masterBuffer()->updateBuffer();
                wa = addWorkArea(*newBuffer);
+               // scroll to the position when the file was last closed
+               if (lyxrc.use_lastfilepos) {
+                       LastFilePosSection::FilePos filepos =
+                               theSession().lastFilePos().load(newBuffer->fileName());
+                       wa->bufferView().moveToPosition(filepos.pit, filepos.pos, 0, 0);
+               }
        } else {
                //Disconnect the old buffer...there's no new one.
                disconnectBuffer();
@@ -1811,13 +1817,6 @@ Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
 
        setBuffer(newBuffer);
 
-       // scroll to the position when the file was last closed
-       if (lyxrc.use_lastfilepos) {
-               LastFilePosSection::FilePos filepos =
-                       theSession().lastFilePos().load(filename);
-               documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
-       }
-
        if (tolastfiles)
                theSession().lastFiles().add(filename);