Author Topic: Bug editing scripts using an external editor  (Read 3364 times)

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Bug editing scripts using an external editor
« on: 2013 December 11 15:29:47 »
I have found a bug when editing scripts using an an external editor in Win7x64:
In previous versions of PI when I saved an script from outside PI and the script was open in PI, PI showed a message notifying that the file had been modified outside PI and asked if I wanted to reload the new version. The latest version (1.8.0.1065) in Win7x64 doesn't show the message, the script inside PI gets marked as modified and when trying to execute it it says: "About to overwrite a newer version of file:....".

I think this is a bug since I have not modified the file inside PI, and it should not get marked as modified.

The steps for reproduce this are:
  • Open any script in PI.
  • Open the same file in an external editor such as Notepad.exe, modify it, save and close.
  • The script gets marked in PI with a exclamation icon.
  • Execute the script with F9. An alert window opens with the message "About to overwrite a newer version of file:....".

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Bug editing scripts using an external editor
« Reply #1 on: 2013 December 11 16:37:06 »
Hi Andrés,

Scripts are always executed from existing disk files, never from source code in memory. Before running a script from the Script Editor window, PI first verifies that the version that you have in the editor is either current or newer than the corresponding file. If the document has been newly created, you are asked to save it before execution. If the document has been previously loaded from or saved to a disk file and it has been modified, it is saved automatically before execution. However, if the existing file has been modified outside of PixInsight's editor, we have a risky situation: you are about to overwrite a newer version generated by an external application, and most likely you're doing so inadvertently.

In previous versions of PixInsight, when an editor file was modified by an external application, PI notified you immediately with a message box. This was causing problems with spurious filesystem notifications and multiple file change events, especially on Mac OS X. In the new versions, external modification events are captured and filtered in a robust way, and are never notified "aggressively" (just by changing the file item icon to a warning sign). The decision to either reload or overwrite an externally modified file is postponed until the necessity arises. This strategy is much more efficient and secure.

In the final 1.8.0 version, attempting to execute an externally modified script is not allowed. You have to either reload it, or save it before execution. The purpose of all of these limitations is to prevent accidental losses of source code.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline mschuster

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1087
Re: Bug editing scripts using an external editor
« Reply #2 on: 2013 December 11 16:46:19 »
The "external application" modifying a file open in the editor could be a running script. When this happens I see a warning dialog while the script is running, at least sometimes. A bit confusing at first, I didn't remember that the file was open, but it seems reasonable now. I also sometimes see time-stamp errors, but I think these are due to the same editor/script situation and are OK.

Thanks,
Mike

Offline Andres.Pozo

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 927
Re: Bug editing scripts using an external editor
« Reply #3 on: 2013 December 12 01:28:15 »
Hi Juan,

using an external editor is very important for me. Although PI has a quite good editor, I am using WebStorm that it is MUCH better: it has autocompletion, code formating, multiple code panels, jump to declaration, refactor, integration with Mercurial, ....

The behaviour of the integrated editor until the previous version was fine for me. I open the scripts in PI only for being able to execute them using the F9 command and I never modify them in PI. Until the last version, when I externally modified a file open in PI, PI showed a message giving me the option of reloading it. It would be nice of still having this capability.

In the last version, when I modify a script, I have to remove it from the editor, select the open option, find the script in the open dialog and then hit F9.

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: Bug editing scripts using an external editor
« Reply #4 on: 2013 December 12 05:23:38 »
Juan,
my style of work is similar to that of Andres. A procedure that allows me to use external editors is what I would like to see.

And BTW: I think that allowing external tools such as debuggers or profilers to work with PI is better than integrating everything into PI.

Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)