Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Fuzzy finder: don't force URL to use git SHA revision#22133

Merged
olafurpg merged 3 commits intomainfrom
olafurpg/fuzzy-finder-revision
Jul 27, 2021
Merged

Fuzzy finder: don't force URL to use git SHA revision#22133
olafurpg merged 3 commits intomainfrom
olafurpg/fuzzy-finder-revision

Conversation

@olafurpg
Copy link
Copy Markdown
Contributor

Previously, the fuzzy finder always used URLs that pointed to the exact
active git SHA (example: @cfd12491d0f2675ac630e06a3a040b94f3946f70).
This behavior caused two problems:

  • when using the fuzzy finder, your URL can't point to a branch name
    like @main. You have to manually edit the URL if you want it to
    point to a non-SHA URL.
  • if you activated the fuzzy finder in a non-SHA URL
    (like @main) then you always re-downloaded the filenames the next
    time you activated the fuzzy finder (because your URL changed to a SHA
    URL like @cfd12491d0f2675ac630e06a3a040b94f3946f70).

This commit updates the fuzzy finder to use the revision (@main)
URL, if it's available. This change fixes both problems above.

@olafurpg olafurpg added the team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) label Jun 16, 2021
@olafurpg olafurpg requested a review from a team June 16, 2021 18:32
@olafurpg olafurpg self-assigned this Jun 16, 2021
@olafurpg olafurpg mentioned this pull request Jun 16, 2021
25 tasks
@olafurpg olafurpg force-pushed the olafurpg/fuzzy-finder-revision branch from 75cfed7 to 3ae24bd Compare June 16, 2021 18:34
Comment thread client/web/src/components/fuzzyFinder/FuzzyModal.tsx Outdated
@olafurpg olafurpg requested a review from felixfbecker June 17, 2021 11:49
@olafurpg olafurpg added this to the Fuzzy finder GA milestone Jun 18, 2021
Comment thread client/web/src/components/fuzzyFinder/FuzzyModal.tsx Outdated
@olafurpg olafurpg force-pushed the olafurpg/fuzzy-finder-revision branch from 3ae24bd to 5552f7c Compare July 26, 2021 11:59
Previously, the fuzzy finder always used URLs that pointed to the exact
active git SHA (example: `@cfd1249`).
This behavior caused two problems:

- when using the fuzzy finder, your URL can't point to a branch name
  like `@main`. You have to manually edit the URL if you want it to
  point to a non-SHA URL.
- if you activated the fuzzy finder in a non-SHA URL
  (like `@main`) then you always re-downloaded the filenames the next
  time you activated the fuzzy finder (because your URL changed to a SHA
      URL like `@cfd1249`).

This commit updates the fuzzy finder to use the revision (`@main`)
URL, if it's available. This change fixes both problems above.
@olafurpg olafurpg force-pushed the olafurpg/fuzzy-finder-revision branch from 5552f7c to 9164ed4 Compare July 27, 2021 09:19
Comment thread client/shared/src/util/url.ts Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated signature to allow an undefined revision field (when the revision is not defined in the URL, like https://sourcegraph.com/jdk/8/-/blob/java/util/Iterator.java#L113:18&tab=references )

This change fixes the URL rendering logic so that we no longer generate
invalid URLs.
@olafurpg olafurpg force-pushed the olafurpg/fuzzy-finder-revision branch from 9164ed4 to dcc01d8 Compare July 27, 2021 09:22
// Parse the URL here instead of accepting it as a React prop because the
// URL can change based on shortcuts like `y` that won't trigger a re-render
// in React. By parsing the URL here, we avoid the risk of rendering links to a revision that
// doesn't match the active revision in the browser's address bar.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: changes the the URL should always trigger a rerender, because the location prop should change (it's an immutable object, meaning it gets a new reference on every change). If it doesn't rerender, that may mean some component may have a bad componentShouldUpdate() implementation that ignores its updates, which would be a bug we'd fix ideally. Or maybe something else is going on.

Anyway I don't think you need to solve this, this is probably fine for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. It was surprising when the component didn't re-render after triggering the y shortcut.

@olafurpg olafurpg merged commit 3ddddc2 into main Jul 27, 2021
@olafurpg olafurpg deleted the olafurpg/fuzzy-finder-revision branch July 27, 2021 10:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team/graph Graph Team (previously Code Intel/Language Tools/Language Platform)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants