GoogleChromeLabs / link-to-text-fragment

Browser extension that allows for linking to arbitrary text fragments.
https://chrome.google.com/webstore/detail/link-to-text-fragment/pbcodcjpfjdpcineamnnmbkkmkdpajjg
Apache License 2.0
412 stars 33 forks source link

Failure message is imprecise/wrong #65

Closed goleary closed 2 years ago

goleary commented 2 years ago

When I try to make a particular text fragment on a particular document that is super long the extension fails and I am presented with a message that says:

Couldn't create a unique link, please select a longer sequence of words.

The thing is the fragment-generation-utils returns a status which specifies numerous different reasons for fragment generation failure.

export const GenerateFragmentStatus = {
  SUCCESS: 0,            // A fragment was generated.
  INVALID_SELECTION: 1,  // The selection provided could not be used.
  AMBIGUOUS: 2,  // No unique fragment could be identified for this selection.
  TIMEOUT: 3,    // Computation could not complete in time.
  EXECUTION_FAILED: 4  // An exception was raised during generation.
};

But the extension reports them to the user all in the same way.

image

In the instance referenced above the util fails due to timeout. When I overwrite the timeoutDurationMs to be 2000 (instead of 500) I am able to obtain a link with text fragment.

tomayac commented 2 years ago

Fixed via https://github.com/GoogleChromeLabs/link-to-text-fragment/commit/3c5da4ed89d0fe2528ada436532a9dae30f49a3c.