Sign in to follow this  
Followers 0
ineedh3lp

Prevent Tidy from reopening file

27 posts in this topic

#1 ·  Posted (edited)

Hello,

Is there a way to prevent Tidy from reopening a file after tidying up? Whenever I tidy up code, the file gets reopened and I lose collapsed lines states, bookmarks, etc.

The only solution seems to be saving a session before tidying up and then reloading the session after tidying up to retain all visual markers.

Also, would be nice if SciTE could write and save collapsed lines states, bookmarks and whatever other kind of information that's not AU script to a INI file named after the script and then load the script view settings from it (basically reloading bookmarks, keeping collapsed code lines collapsed, etc).

Edited by ineedh3lp

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

When running Tidy from within SciTE the process is:

- SciTE saves the file and shells Tidy.exe.

- Tidy reads the file and after prcessing saves it to the original filename.

- SciTE detects the source file is updated and will reopen the new one.

Add this line to your SciTEUser.properties to maintain the Bookmarks:

session.bookmarks=1

Don't think that maintaining Folds is currently possible.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I found this in the SciTE help file:

session.bookmarks

session.folds

Setting session.bookmarks causes bookmarks to be saved in session files. If you set session.folds then the folding state will be saved in session files. When loading a session file bookmarks and/or folds are restored. Folding states are not restored if fold.on.open is set.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you both. I have added:

session.bookmarks=1

session.folds=1

to the SciTEUser.properties file, but the bookmarks and folds are still lost after tidying up the code. I believe that's because only the script file is reopened and not the session. Probably the only fix to this is to write settings separately per script and have SciTE load them when a script is opened.

Edited by ineedh3lp

Share this post


Link to post
Share on other sites

You can turn off load.on.activate so that SciTE won't reload a changed file automatically.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

But doesn't that mean I have to reload the file manually (by re-opening it) which leads to loosing the bookmarks and folds again?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You could manually do a save session, then load session after running Tidy. This will save the folds and/or bookmarks and reload them, as well as reload the file.

EDIT: You could also write a Tool for yourself that automatically saves the session, then runs Tidy, then loads the session. I have no experience with using Lua so I can't be of much help there.

Edited by BrewManNH
1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

You could manually do a save session, then load session after running Tidy. This will save the folds and/or bookmarks and reload them, as well as reload the file.

The only solution seems to be saving a session before tidying up and then reloading the session after tidying up to retain all visual markers.

EDIT: You could also write a Tool for yourself that automatically saves the session, then runs Tidy, then loads the session. I have no experience with using Lua so I can't be of much help there.

Yeah, I thought of that either and I'll probably create a macro for it since there's no clean solution yet.

Thanks for the support!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

The save bookmarks should work and do so for me.

See here for what I have implemented in Tidy to accomplish this:

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have these at the bottom of the user properties

save.session=1
save.position=1
session.bookmarks=1
session.folds=1

and these in the global options

save.recent=1
save.session=1
session.bookmarks=1
session.folds=1
save.position=1

yet bookmarks still don't display after tidying.

Share this post


Link to post
Share on other sites

Yes, 1 instance, multiple tabs.

SciTE

Version 2.27

Jun 24 2011 17:46:25

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Ok, and how are you starting Tidy: With Ctrl+T or F5/F7 using the Directive.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I'm using Ctrl+T.

Testing on an earlier example script posted by Melba

#region

$fred = 1
If $fred Then
        #Tidy_Off
        $tom   = 1
        $dick  = 1
        $harry = 1
        #Tidy_On
EndIf

#endregion

so no directives.

When running Tidy, it looks like it goes through all opened scripts, so I'm assuming it does reopen the current session, but doesn't keep the bookmarks for the current script.

Share this post


Link to post
Share on other sites

Well it works for me so we need to do some debugging to sort this out.

The linked post describes the exact way I made it work in Tidy: it will:

- save the session to a file in %temp%\tidyscite.session

- Update the file

- Reload into SciTE

- Open the tidyscite.session file and add the Bookmarks one at a time by sending command to SciTE via the Director interface.

I am off for the rest of the day and will not be available the next couple of days.

What you could do for me is download the current Tidy.exe version from the Beta dir and run it against a File with bookmarks.

Then PM me file "%temp%\tidyscite.session" and the filename you Tidied

Will have a look at it when am back online.

Jos :graduated:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

- Open the tidyscite.session file and add the Bookmarks one at a time by sending command to SciTE via the Director interface.

Could you please instruct me how to do this? I'm not sure I understood correctly from the SciTE Director Interface documentation. Edited by ineedh3lp

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

No need to understand that for this case.... just send me the requested stuff and I will have a look to see if there is anything obvious.

When not, I will come back to you probably with a "special" tidy version to add some extra debugging steps to it so I can see what is happening.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Hmm, here's what's happening:

1. Saving the session to C:\Users\ineedh3lp\AppData\Local\Temp\tidyscite.session (file is saved and is visible)

2. Reloading the session from C:\Users\ineedh3lp\AppData\Local\Temp\tidyscite.session (file is still there)

3. Tidying any script and the file is gone, regardless of using bookmarks or not.

Is that normal? because if not, maybe that's the issue.

Edited by ineedh3lp

Share this post


Link to post
Share on other sites

Normally ..yes, as i want to clean up temp stuff, but the in latest BETA version I have commented the deletion of the tidyscite.session file.

I just re-iploaded Tidy.exe to make sure the correct version is there.

Try using that version.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

OK, so I downloaded the latest from: http://www.autoitscript.com/autoit3/scite/download/beta_SciTE4AutoIt3/Tidy.exe

Now it doesn't delete the temp file anymore.

Saved the session, reloaded it, placed bookmarks and then tidied. Guess what? When I check the session with a text editor, it shows the bookmarks as buffer.9.bookmarks=5,8 which is correct. The only issue is that the bookmarks do not display... could it be that it just writes to the session file but then doesn't load from it?... Aww, shitee, man, that must be it... my session originates from a different session, so it seems that it doesn't matter if I save the session to the temp file and then reload it from the temp file, it still loads the old session file after tidying.

If I open two script files, place some bookmarks, close the session, start SCITE then tidy scripts with bookmarks, the bookmarks are still there. Heh... I'll research some more.

Thank you for all the support!

Edited by ineedh3lp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0