Skip to content

Instantly share code, notes, and snippets.

@darkwing
Last active March 26, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkwing/c0a6e3eaf04cb5c1caea75df6b7e397a to your computer and use it in GitHub Desktop.
Save darkwing/c0a6e3eaf04cb5c1caea75df6b7e397a to your computer and use it in GitHub Desktop.
Mo selectLocation mo problems

Fixing selectLocation Madness

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:

Duplicate Tabs

If a pretty-printed tab is already open, the next time selectLocation is called for a given source, the original source tab is opened.

Places this happens

  • 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
  • ...

Why it's bad

It's confusing and frustrating to have two tabs open.

Desired Functionality

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.

How to Fix

.....

Open & Close

In order to open a pretty-printed tab, the original source's tab must be opened and then closed.

Places this happens

Every single time selectLocation is called when auto-pretty-print is on.

Why it's bad

  • 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.

Desired Functionality

The pretty-printed tab should be the only tab ever opened, thus cutting down on loads of work.

How to Fix

....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment