How can i revert all the changes made onto the document through jsx script? - adobe-illustrator

I want any of the way that can help me to revert all the changes that are made on the document ,like through Jsx script I made changes in the document like placing image re-sizing image changing swatches etc. but at a point of time i want to revert all the changes made through the same jsx code. i'm aware of undo function in Jsx but undo function just revert the recent change (can say last change ) so ,is there any way that can be used to revert all the changes.
Note: one way i know that is to close the document without save changes and reopen the same document. but avoiding this solution.

Wrap the main functionality in the script inside a function, say main(), so that calling main() will run the script.
Now add the following line to the end of the script:
app.activeDocument.suspendHistory('My changes', 'main()');
This will run the main() function and in your History panel you would see a new undo state called 'My changes'. Undoing this would revert all the changes you did from the script.

to go back to the initial history state, just use:
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[0];

Related

How do I expand the changes to view it normally after updating project from Git?

So me and my class mates have recently started using Github to update our project in IntelliJ and it's going great, except I have this really annoying thing where all of the changes are collapsed when I go to the changed class and I can't expand them the usual way.
https://gyazo.com/06e77193750ce9a48cca14bfaa00cd54 This is all I can actually see, but there are 40 lines of code inside the class and 6 lines of imports above the class header, but I can't actually expand the changes to view them like I would in normal code, instead it gives me a pop-up type menu with no option to accept the changes.
Please can someone point me in the right direction? It's driving me insane.
Idea is marking deleted segments (lines) in your code with these grey triangles. It means you have somehow removed these lines (probably unintentionally), and these deletions are now in your working copy (waiting to be commited). You can undo this by selecting Git / Uncommited Changes / Rollback... menu in Idea. It will display a dialog with the changed files you can rollback to the last commited state. You can also right click on each file and select Show Diff to see the changed lines. Be sure not to rollback any changes done intentionally.
Alternatively you can also rollback the changes one-by-one by clicking the grey triangles and pressing the rollback button:

How to save a folded code structure after file close

How can I save folded code structure after file close? It get me a lot of headache to fold a lot of code again each time when I reopen file.
You cannot save the particular state of the code folds as far as I know, but you can collapse certain code regions by default as shown here in the preferences.
What I do is use //region and //endregion for my custom folding code I want collapsed, and use documentation for things I want always seen (like explaining what is inside the code folds' logic where necessary).

Accidental use of built in function as variable name?

I have been writing some VBA code to produce charts automatically, and at one point named a variable "CHARTTITLE" not realizing that this is a member of the Chart object. I have deleted this variable upon realizing my mistake. However, since doing so, wherever I employ something like
Charts(1).ChartTitle.Text =
It will automatically auto-capitalize to
Charts(1).CHARTTITLE.Text
I have tried search and replace over the entire project from .CHARTTITLE to .ChartTitle to no avail. I have also tried employing Option Explicit also without effect. I am worried that there is now some sort of memory issue or that I've overwritten something important. Is there any way to reset this back to its default state?
It's a benign effect and it's a long-standing bug relating to the way that VBA stores itself internally. A couple of things to try:
Change the first occurrence of CHARTTITLE in the module, or if in multiple modules in the first module that appears in the project explorer.
Export the module, remove it from the project, edit it using your favourite text editor and reimport it.

In Intellij IDEA how do I reload file content's from disk?

In vim I can type :e and reload a file's contents from disk overwriting any changes I've made. It's a nice way to reset in case I've gotten lost or just want to undo all my changes. This obviously doesn't take into account any kind of refactoring, I just want to nuke all changes to buffer. Not even closing and reopening a tab will work.
How do I do this with Intellij IDEA? I'm using Intellij IDEA Ultimate 13 and I've disabled any kind of auto save.
File > Synchronize (Ctrl+Alt+Y)
It will load the file from the file system. If you have unsaved changes, it will ask if you want to discard them.
⌥⌘Y - Synchronize for Mac users
What I do in a similar situation:
Simple - Ctrl+Z, Ctrl+Shift+Z many times to quickly navigate the editing history
VCS rollback - either for the whole file or for the area being edited (by clicking green areas on the left)
Local History. Well, yes, for you case it's granularity is not sufficient, so first might be an option
There is also an option to put a label into Local History if you need to rollback to a specific point in time.
For those who use autosave - it is being triggered when code editor loses focus. So doing Alt-Tab during long editing without compiling or running the code makes sense.
Open the file in another editor, make an insignificant change and save it. PHPStorm will ask you what to do because the file system and in memory copies of the file have diverged. Click "Load File System Changes".
Note, I was unable to use my undo history as it had become corrupt.
Since what I want isn't really possible I wrote an extension to do it for me:
https://github.com/btipling/DiskRead/
I'll add it to the Jetbrains plugin repository, it's called "DiskRead".
I wrote a blog post about how I created this if anyone is curious.

How to let IntelliJ IDEA's Local History ignore Plugins' temporary change and restore to document?

I am writing a IntelliJ IDEA plugin at here like AceJump, which is used for fast move caret in IDE.
like following, by apply TextAttributes to all 'i' occurrences, and give each 'i' an index char.
after user press 'H', the caret will move to 'i' in the "private".
then change all Markup chars to original 'i'
PROBLEMS
This action will change the Document contents during jump.
so there will be a history change like below. Is there a way to ignore the changes in Local History management?
After press Cmd-z, there is a dialog says "Cannot Undo". how to avoid this?
Instead of changing the document contents, you should paint your navigation markers over the document using, for example, the HintManager class.
If you change the actual document contents, this will have many more consequences besides breaking undo and local history - for example, the document will be reparsed causing false syntax errors to be displayed; any other plugin or IntelliJ IDEA component watching for changes to the document will react to this; the document will be checked out from the VCS if the user is using a VCS such as Perforce that requires an explicit checkout operation; etc. TL/DR: don't do that.
In case someone google and find here. following is my final solution.
I using Swing graphics drawing to show the markers, works great.
please refer for details: https://github.com/whunmr/emacsIDEAs/blob/master/src/org/hunmr/acejump/marker/MarkersPanel.java