At present the selectLocation
method is trying to do too much, specifically because the auto-pretty-print logic is a bit weak:
if (
prefs.autoPrettyPrint &&
!getPrettySource(getState(), sourceId) &&
shouldPrettyPrint(selectedSource) &&
isMinified(selectedSource)
) {
await dispatch(togglePrettyPrint(sourceId));
dispatch(closeTab(source.get("url")));
}
The following are undesired side effects of selectLocation
:
If a pretty-printed tab is already open, the next time selectLocation
is called for a given source, the original source tab is opened.
- Clicking a source item in the SourcesTree when a prettyprinted tab is selected
- Clicking a resultlist item when a prettyprinted tab is selected
- Clicking a frame item when a prettyprinted tab is selected
- ...
It's confusing and frustrating to have two tabs open.
If the auto-pretty-print pref is on, always, always show the pretty-printed tab unless specifically requesting the original source via the source footer.
.....
In order to open a pretty-printed tab, the original source's tab must be opened and then closed.
Every single time selectLocation is called when auto-pretty-print is on.
- It's an eye-sore to see something open and close without any user interaction
- I don't have metrics but this has to be a major perf killer. All the taxing work that happens when a tab is opened (syntax highlighting, etc.) happens twice, which is really undesirable.
The pretty-printed tab should be the only tab ever opened, thus cutting down on loads of work.
....