# Command: GoRefreshKeepSelection (refresh & keep selected)

**URL:** <https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176>\
**Category:** Buttons/Scripts\
**Tags:** script, commands, jscript\
**Created:** [September 14, 2014, 1:07am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176 "2014-09-14T01:07:00Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [September 14, 2014, 1:07am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/1 "2014-09-14T01:07:00Z")

</div>

GoRefreshKeepSelection - A script command that refreshs tabs and tree content, while keeping the current selection and also scrolling back to the selected items (can be disabled).

**################################################################**  
**THIS SCRIPT ADDIN IS OUTDATED, please use "GoEx":**  
[Command: GoEx (extended Go command functionality)](https://resource.dopus.com/t/command-goex-extended-go-command-functionality/33002)?  
**################################################################**

* * *

Description:  
I made this to refresh a tab and maintain my selection, because I don't like to lose my selection on refreshs (DO default), simple as that! o)

Params / ScriptConfigs and Features:

- DebugOutput, switch to enable printing of details for troubleshooting
- NoScrollToSelection, switch to disable scrolling to selected items
- ScrollToChecked, switch to priorize checked items when scrolling back to selection
- GoRefreshOptions, any valid option for "Go REFRESH"
- GoParams, any additional switch or parameter for the "Go" command

* * *

Usage:  
The usage is quite similar to that of the native "Go REFRESH" functionality.

_Native command:_  
`Go REFRESH`

_Script command:_  
`GoRefreshKeepSelection`

If you'd like to keep selection while refreshing both file displays of a dual lister and also refresh the thumbnails:

_Native command:_  
`Go REFRESH=both REFRESHTHUMBNAILS`

_Script command:_  
`GoRefreshKeepSelection GOREFRESHOPTIONS=both GOPARAMS=REFRESHTHUMBNAILS`

If you'd like to refresh the right file display only:

_Native command:_  
`Go REFRESH=right`

_Script command:_  
`GoRefreshKeepSelection GOREFRESHOPTIONS=right`

Got it? o)

* * *

Installation:  
To install the command, download the \*.js.txt file below and drag it to Preferences / Toolbars / Scripts.  
After that, you should edit your "F5" hotkey to run "GoRefreshKeepSelection" instead of "Go REFRESH".

* * *

Download:

- Latest: v0.2.1 supports automatic updates/scriptwizard:  
[Command.GUI\_GoRefreshKeepSelection.js.txt](https://resource.dopus.com/uploads/default/original/3X/e/6/e61977d7241c912ede0955f3a380dff0cb3ff2fe.txt) (11.2 KB)

- v0.2 - major improvements to fully support all "Go REFRESH" options and additional "Go" switches and parameters:  
[Command.GUI\_GoRefreshKeepSelection.js.txt](https://resource.dopus.com/uploads/default/original/3X/9/c/9c4bb0906e1f4d316ceacfb8eeae3651da53c8d5.txt) (10.1 KB)

- v0.1 - initial version:  
[Command.GUI\_GoRefreshKeepSelection.js.txt](https://resource.dopus.com/uploads/default/original/3X/2/9/2912fd9598bf696461fbfa09563d3134ebf59f3d.txt) (6.84 KB)

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [September 14, 2014, 5:45am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/2 "2014-09-14T05:45:39Z")

</div>

Many thanks for providing this really useful script.

Feature Request:

- When changing the Refresh command to Go Refresh=both (or dest or all) the selection in destination should also be kept.

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [September 14, 2014, 7:39am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/3 "2014-09-14T07:39:17Z")

</div>

Hallo Kundal! o)

I guess I see the reason for your request, but I think you can just run the command twice, whereever you change the default refresh command for GoRefreshKeepSelection to "Go REFRESH=both", or am I wrong?

Thanks for dropping in! o)

EDIT: Oh, I just noticed, "Go REFRESH=dest" is not yet working as it should, so my idea to run it twice won't work. I'll see what I can do about it.

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [September 14, 2014, 8:34am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/4 "2014-09-14T08:34:04Z")

</div>

Hi tbone,  
I modified your script and got it working for Go REFRESH=all , both and dest (checkbox mode not tested).

Edit: attached script removed

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [September 14, 2014, 11:50am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/5 "2014-09-14T11:50:55Z")

</div>

Updated to v0.2

- major improvements to fully support all "Go REFRESH" options and additional "Go" switches and parameters
- attention: changes in parameter names, config items and maybe general handling
- updated the "Usage" section to reflect all changes

@kundal  
Thanks for your help! o) But please remove your version. o) It errors for single listers and generally cannot work satisfyingly.  
A more generic approach is needed to really take care of selections, checkbox mode and additional refresh options.

I also noticed a possible DO "issue" with Tab.Update(). It seems the method does not update the tab object synchroniously.  
So a special handling (looping while updating the tab) is needed to get the script to sync with the GUI again.

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [September 14, 2014, 12:49pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/6 "2014-09-14T12:49:32Z")

</div>

Many thanks for the now full-featured script. Works great.

> [@tbone](#):
>
> But please remove your version.

Done.  
I know it was a really dirty thing but it worked (maybe only) for my standard usecase: dualpane - no checkbox - refresh all.  
I'm far away from your knowledge about scripting and studying/hacking your scripts is always a great challenge and fun for me. 😃

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [September 14, 2014, 4:22pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/7 "2014-09-14T16:22:58Z")

</div>

> [@](#):
>
> Many thanks for the now full-featured script. Works great.

I'm glad to hear! o) Time will tell if it really works stable and covers all use cases, let's hope the best.  
The fun is also on my side, so I hope to read you soon - in the GoRegistry thread maybe? o)

---

<div class="post-metadata">

**Author:** ![kundal](https://resource.dopus.com/user_avatar/resource.dopus.com/kundal/32/24277_2.png) [@kundal](https://resource.dopus.com/u/kundal)\
**Post date:** [September 14, 2014, 4:46pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/8 "2014-09-14T16:46:15Z")

</div>

> [@tbone](#):
>
> I hope to read you soon - in the GoRegistry thread maybe? o)

Most certainly. Can't wait for the new version...

---

<div class="post-metadata">

**Author:** ![Lezgus](https://resource.dopus.com/letter_avatar_proxy/v4/letter/l/ac91a4/32.png) [@Lezgus](https://resource.dopus.com/u/Lezgus)\
**Post date:** [September 23, 2014, 6:54pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/9 "2014-09-23T18:54:30Z")

</div>

Hello tbone,

great Script. Thank you for sharing.  
One Question please. Is there a way to use this Script in Flat View Mode?

Excuse my insufficient English skills, please.

Thanks  
Lezgus

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [September 25, 2014, 9:28am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/10 "2014-09-25T09:28:02Z")

</div>

Should work fine in flatview mode, it does so for me at least.

---

<div class="post-metadata">

**Author:** ![Lezgus](https://resource.dopus.com/letter_avatar_proxy/v4/letter/l/ac91a4/32.png) [@Lezgus](https://resource.dopus.com/u/Lezgus)\
**Post date:** [September 25, 2014, 9:40am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/11 "2014-09-25T09:40:16Z")

</div>

Hello tbone,

you are right. Sorry my mistake.  
It's was an "error" in combine with an other script.

Thank you  
Lezgus

---

<div class="post-metadata">

**Author:** ![carter](https://resource.dopus.com/user_avatar/resource.dopus.com/carter/32/37354_2.png) [@carter](https://resource.dopus.com/u/carter)\
**Post date:** [July 2, 2019, 2:46pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/12 "2019-07-02T14:46:07Z")

</div>

After a refresh is done,the first file in the lister is also getting selected including the one on which selection is already there,will u pls correct it

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [July 2, 2019, 2:51pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/13 "2019-07-02T14:51:08Z")

</div>

You may just need to turn off **Preferences / File Displays / Options / Automatically select first file in folder (except in Power Mode)**.

---

<div class="post-metadata">

**Author:** ![carter](https://resource.dopus.com/user_avatar/resource.dopus.com/carter/32/37354_2.png) [@carter](https://resource.dopus.com/u/carter)\
**Post date:** [July 2, 2019, 3:21pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/14 "2019-07-02T15:21:36Z")

</div>

I want the above setting to work with refresh,i use it.

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [July 2, 2019, 8:33pm UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/15 "2019-07-02T20:33:13Z")

</div>

Maybe try GoEx, find it here. It is a newer and extended version of what this script addin here provides:

> [@Command: GoEx (extended Go command functionality)](https://resource.dopus.com/t/command-goex-extended-go-command-functionality/33002):
>
> Introduction: This script addin provides extended Go-command functionality. It tries to provide an all-in-solution to existing script-addins and also tries to enhance some of them. [https://resource.dopus.com/t/command-go-relative-go-to-next-prev-…](https://resource.dopus.com/t/command-go-relative-go-to-next-prev-sibling-folder/20597)

---

<div class="post-metadata">

**Author:** ![tbone](https://resource.dopus.com/user_avatar/resource.dopus.com/tbone/32/25726_2.png) [@tbone](https://resource.dopus.com/u/tbone)\
**Post date:** [July 3, 2019, 7:20am UTC](https://resource.dopus.com/t/command-gorefreshkeepselection-refresh-keep-selected/19176/16 "2019-07-03T07:20:56Z")

</div>

@carter  
I just tried the native Go REFRESH command, it also selects the first item (if enabled in the prefs), so my impression is, this is something only Jon and Leo could work on, maybe the auto selection could be skipped upon refresh or whenever some kind of "NOFIRSTITEMSEL" switch is passed to the Go command.
