#445 Enhancement: Folding state is restored by sessions

Next_release
closed
nobody
None
1
2013-04-21
2013-01-11
FLS
No

Folding state is now saved and restored by "sessions".

Furthermore, with this patch, the session information of a number of recently opened files are saved like for a session but independently.
Whenever a file is closed, the session information is written into an extra node (FileEditViewHistory) into the config.xml file. The list of files in this node is managed like the node for the history of recently opend files.
Whenever a file is opened, and this feature is enabled, the filename is searched in the list of files in the FileEditViewHistory-node.
When it is found, the session information for that file is restored.
The Settings-Preferences-MISC dialog is enhanced with a checkbox to enable/disable this functionality and the possibility to set the number of files to remember.

Patch is based on NPP 6.2.3 (SVN 969)

Patch: NppPatch_6.2.3_SessionFoldingRestore.patch
- Commentcode:
xSaveFoldingStateSession: for saving / restoring the folding
xFileEditViewHistory: for the basic functionality of session information per file
xFileEditViewHistoryParameterGUI: for the Settings-Preferences-MISC dialog upgrade
FLS

1 Attachments

Discussion

  • Don HO
    Don HO
    2013-02-18

    • status: open --> accepted
    • priority: 5 --> 8
     
  • Don HO
    Don HO
    2013-02-18

    Thank you for your very helpful contribution.
    Committed in SVN (rev. 1024).
    This feature will be in the next release.

    Don

     
  • FLS
    FLS
    2013-02-23

    In the patch above, the resources for the GUI part were missing.

    Therefore, the Settings-Preferences-MISC dialog is NOT enhanced with a checkbox to enable/disable this functionality and the possibility to set the number of files to remember.

    Don, please add that patch also to NPP to get the enable/disable checkbox into the dialog.

    Sorry,
    FLS

     
    Last edit: FLS 2013-03-29
  • Don HO
    Don HO
    2013-04-02

    This feature has the performance issue in 6.3.1

    In my case, 856 file opened with the patch (6.3.1), it takes 24 seconds to load (by using "-loadingTime" argument to measure). Without patch it takes 16 seconds - there is no folding applied in opened files (see attached file), so the 8 seconds is not tolerable.
    IMO there's still the room to improve the performance, I'll take a look at it. In the meantime, this feature will be removed in v6.3.2 to fix the performance issue.

    Don

     
    Attachments
  • FLS
    FLS
    2013-04-16

    Dear Don,

    during developing the “remember folding states between session” and the “FileEditViewHistory” feature, I tried to keep the whole code sequence as it was and also to reuse as much code and subroutines as possible. Doing so, I found mainly the following issues:

    I.) For restoring view elements like markers, selections, caret position and folding states, it is on the one hand necessary to store them into the FileManager buffers and on the other hand to task Scintilla. This leads sometimes to odd effects, because already available subroutines revert something, which is already done during restoring some view elements. In the end the whole procedure is nearly equivalent with loading a file three times. And that is time consuming.

    II.) There is a big difference between
    a.) loading the first file, when there is no other file loaded in NP++ (i.e. only the “new x” tab).
    b.) loading the second file, when there is already another file loaded in NP++ (or for the second file when reloading a session).

    When the code sequence for restoring worked for b.) there were strange effects for a.). Mainly when switching back from the second file to the first file, the lexing got lost for the first file or some valid settings for the second file were applied to the first file.
    This forced me to do extra work (subroutine calls) to intermediately synchronize the FileManager buffer parameters with the Scintilla calls and vice versa.

    For performance optimisation on loading a file and having the possibility of restoring edit view settings in an easy way, I believe it is necessary to rework and shape the subroutines for file loading and edit-view switching completely new to avoid the mentioned double work.

    For the people who need the restore of folding state and the “FileEditViewHistory” feature, I have included a preference parameter option to switch the “remember folding state” on optionally. By default, it is switched off. Please see the attached patch.

    FLS

     
  • Don HO
    Don HO
    2013-04-21

    FLS,

    A new optimized algorithm has been implemented and committed in the trunk (rev. 1036).
    This algorithm doesn't apply syncFoldStateWith on each file in session. Instead, it copies the folding states to each buffer.
    The routine syncFoldStateWith has been modified to fix the folding problem of SCI_TOGGLEFOLD which don't act on the first loading.
    Some of structures/routines are removed or shortened and the result is quite satisfied:
    Same 856 files in session without folding states are tested,
    6.3.1 (no remember folding on session feature): 26 sec
    6.3.3 (with remember folding on session feature): 18 sec

    As a result, the rev. 1036 will be kept. Thank anyway you for your patch.

    Don

     
  • Don HO
    Don HO
    2013-04-21

    • status: accepted --> closed
    • Priority: 8 --> 1