From 641b2dff16b6d961923a75c1c1cc525cfacdaaf5 Mon Sep 17 00:00:00 2001 From: Youen Toupin Date: Wed, 23 Nov 2016 14:08:09 +0100 Subject: [PATCH] restoring scroll position when loading a client config only if the file was not already loaded --- server/wxLdb/ui/mainWindow.lua | 4 +++- server/wxLdb/wxLdbController.lua | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/wxLdb/ui/mainWindow.lua b/server/wxLdb/ui/mainWindow.lua index 5d9d176..bff39cd 100644 --- a/server/wxLdb/ui/mainWindow.lua +++ b/server/wxLdb/ui/mainWindow.lua @@ -266,7 +266,9 @@ end function meta.__index:getSourcePage( source ) local page = self.sourcePages[source] + local newlyLoaded = false if page == nil then + newlyLoaded = true page = mainthread.execute( function() return ui.sourcePage.new( self.sourceBook, source ) end ) self.sourcePages[source] = page local _, _, name = string.find( source, ".*[/\\](.*)" ) @@ -280,7 +282,7 @@ function meta.__index:getSourcePage( source ) page:registerEvent( "onBreakPointChanged", function( ... ) self:runEvents_( "onBreakPointChanged", source, ... ) end ) page:registerEvent( "onScrollChanged", function( ... ) self:runEvents_( "onScrollChanged", source, ... ) end ) end - return page + return page, newlyLoaded end function meta.__index:findSourcePage( source ) diff --git a/server/wxLdb/wxLdbController.lua b/server/wxLdb/wxLdbController.lua index 2745cff..cdff091 100644 --- a/server/wxLdb/wxLdbController.lua +++ b/server/wxLdb/wxLdbController.lua @@ -823,8 +823,8 @@ function meta.__index:loadConfig_( name ) end for _, file in ipairs( config.openFiles ) do - local page = self.window:getSourcePage( file ) - if page ~= nil then + local page, newlyLoaded = self.window:getSourcePage( file ) + if page ~= nil and newlyLoaded then local sp = clientConfig.scrollPositions[file] print("scroll to", sp) if sp ~= nil then