#296 Improve behaviour when a change to an open file is detected

open
nobody
None
3
2013-06-05
2012-06-11
Kirill Müller
No

The current behavior when a file that is open in TeXStudio is changed externally is less than satisfactory. To illustrate:

  • Open a file, say, test.tex
  • Edit it with another tool, say, echo >> test.tex
    --> TeXStudio shows a dialog

Problems:

  • I do not want to be nagged by a dialog, instead the file should be reloaded automatically
  • I don't mind if a dialog is shown if this can be turned off with a configuration option
  • The undo history could be well preserved by making the external update one single modification in the undo history

That's the way eclipse and Visual Studio handle it, that's what I believe is state of the art. If you feel like going beyond the state of the art, consider the following behavior:

  • Instead of adding the whole file contents to the history, perform a diff of the current state in TeXStudio to the new file state and add all changed chunks one by one. This automatically handles the case when the file hasn't been changed but its timestamp has been updated.

The funny thing is: When trying to replicate the behavior, the dialog doesn't show up anymore. The only thing that I have changed to my system is the installation and one-time usage of TeXMaker. Where does TeXStudio store its configuration? -- While the dialog doesn't bother me anymore (by now), the enhanced undo stack remains a valid request.

Discussion

  • Tim Hoffmann
    Tim Hoffmann
    2012-06-11

    It's not so easy to update, because TXS maintains internal information on the document (structure, labels etc.). Currently an "update" on external changes works like close-reopen. Therefore the undo/redo stack is lost.

    You can have the following cases:
    i) no changes at all
    ii) changes, but the current version is the same as the one on disk (i.e. either saved or changes undone).
    iii) Unsaved changes

    i) does not pop up a dialog, because its safe to update in this case. ii) asks the user, because the undo/redo stack is gone after the update, which potentially can lead to a loss of data. For this case we may add an option (default off), to auto-update, knowing the risk of clearing the undo stack.
    iii) would require a diff and merge (anyway automatic handling would only be possible if there is no conflict). IMHO that's not so easy. I think it will not come in near future, because there are more important things to work on. The same is true for the enhanced undo stack.

     
  • Kirill Müller
    Kirill Müller
    2012-06-11

    In the case of ii), instead of close-reopen the whole document contents should be replaced in one undoable command. This shouldn't be too difficult, and the internal cache for the document structure should be rebuilt as well. This is akin to copying the contents of one .tex file and pasting it into another already opened .tex file.

    The diff-and-merge required for iii) is challenging, yes. But as I mentioned, using the same behavior as for ii) (perhaps with a warning message).

    So: Turning off the nag dialog for ii) should be easy, but perhaps you see problems I am unaware of that disallow an easy implementation of the enhanced undo stack.

     
  • Kirill Müller
    Kirill Müller
    2012-06-11

    Unfinished second paragraph in the previous comment: ...using the same behavior as for ii) (perhaps with a warning
    message) would be good already, too.

     
  • nstead of close-reopen the whole document contents should be replaced in one undoable command. This shouldn't be too difficult,

    The only difficulty is that for large documents, the file is not loaded completely in one pass, but in chunks which are then added to the document separately

    The diff-and-merge required for iii) is challenging, yes.

    Actually there is already a diff-and-merge (at least in the svn version)

    However, the current implementation makes things worse, because now two dialogs are shown: The old dialog, and a "do you want to diff and merge?"-dialog afterwards.

    And it doesn't work so well with changes, since it inserts the old and new version in the text.

     
    • Dellu
      Dellu
      2013-04-08

      exactly, two dialog boxes, so annoying and tiring if u constantly modify with another tool (editor).

       
  • Kirill Müller
    Kirill Müller
    2012-06-13

    Instead of close-reopen the whole document contents should be replaced in
    one undoable command. This shouldn't be too difficult,

    The only difficulty is that for large documents, the file is not loaded
    completely in one pass, but in chunks which are then added to the document
    separately

    I still don't see the problem. Does that matter in terms of undo operations? Or in terms of performance?

    I'm checking out the SVN code and will be looking into it. What kind of IDE are you using for development?

     
  • What kind of IDE are you using for development?
    Qt Creator

    And the loading happens in QEditor::load, QDocument::load

    On 06/13/12 09:16, SourceForge.net wrote:

    Feature Requests

     
  • Dellu
    Dellu
    2013-04-08

    Yes, the implementation of the two other requests might be secondary. But, I think the first request ( the autoupdate) is really crucial for the end user. The nagging text in Textstudio is also horrible, hard to understand and so annoying. I am now migrating to Texshop because of the lack of automatic update because autoupdate is really crucial for my work flow. I love texstdio and used it for more than 3 years. Please include this feature in the next release.

     
  • Tim Hoffmann
    Tim Hoffmann
    2013-04-11

    An option to switch this off (for case ii) from above) has been implemented in SVN rev. 3872 (Configure -> Advanced Editor -> Special Options). A win installer of an 3883 snapshot is available at https://sourceforge.net/projects/texstudio/files/texstudio/TeXstudio%20SVN/.).

     
    Last edit: Tim Hoffmann 2013-04-11
  • Kirill Müller
    Kirill Müller
    2013-06-05

    Will test once I have access to the new version. Currently, qmake texstudio.pro gives me the following error (Ubuntu 13.04):

    Project MESSAGE: Creating debug version
    Project WARNING: CONFIG+=uitools is deprecated. Use QT+=uitools instead.
    Project ERROR: Unknown module(s) in QT: uitools script svg