Skip to content

No "open in new tab" option after right clicking an identifier #30

Description

@seagreen

Right click followed by "open in new tab" works for me for the files in the sidebar, but not for identifiers. Instead I see:
screenshot

Activity

  1. seagreen commented on Mar 24, 2019

    @seagreen
    ContributorAuthor

    The top of "distDir" is cut off due to an Ubuntu screenshotting issue, not the fault of haskell-code-explorer.

  2. alexwl commented on Mar 26, 2019

    @alexwl
    Owner

    There is no "Open Link in New Tab" in the context menu because each identifier (e.g., distDir) is a span HTML element, not an anchor.

    A click on an identifier is handled by JavaScript:

    function goToDefinition(store,locationInfo,buttonId,currentLineNumber) {
    if(locationInfo.tag === "ExactLocation") {
    const url = exactLocationToUrl(locationInfo);
    if(locationInfo.startLine !== currentLineNumber) {
    saveCurrentLocation(currentLineNumber);
    }
    openUrl(buttonId,url);
    } else if((locationInfo.tag === "ApproximateLocation") &&
    (locationInfo.moduleName.indexOf("Paths_") !== 0)) {
    const packageId = locationInfo.packageId.name+"-"+locationInfo.packageId.version;
    if(locationInfo.entity === "Mod") {
    store.loadDefinitionSite(packageId,
    locationInfo.moduleName,
    locationInfo.componentId,
    locationInfo.entity,
    locationInfo.moduleName)
    .then((defSite) => {
    const packageId = defSite.location.packageId.name + "-" + defSite.location.packageId.version;
    openUrl(buttonId,"/package/" + packageId + "/show/" + defSite.location.modulePath);
    }).catch(() => {
    openUrl(buttonId,hackageUrl(packageId,locationInfo));
    });
    } else {
    store.loadDefinitionSite(packageId,
    locationInfo.moduleName,
    locationInfo.componentId,
    locationInfo.entity,
    locationInfo.name)
    .then((definitionSite) => {
    if(definitionSite.location.tag === "ExactLocation") {
    const url = exactLocationToUrl(definitionSite.location);
    if(locationInfo.startLine !== currentLineNumber) {
    saveCurrentLocation(currentLineNumber);
    }
    openUrl(buttonId,url);
    } else {
    saveCurrentLocation(currentLineNumber);
    openUrl(buttonId,hackageUrl(packageId,locationInfo));
    }
    }).catch((e) => {
    console.log(e);
    saveCurrentLocation(currentLineNumber);
    openUrl(buttonId,hackageUrl(packageId,locationInfo));
    });
    }
    } else {
    alert('No location info');
    }
    }

    • Left mouse click on an identifier updates the current browser tab.
    • Middle mouse click on an identifier opens a new browser tab (that tab may be blocked by a popup blocker).
    • There is no handler for the "right mouse click" event.
  3. seagreen commented on Mar 29, 2019

    @seagreen
    ContributorAuthor

    There is no "Open Link in New Tab" in the context menu because each identifier (e.g., distDir) is a span HTML element, not an anchor.

    Is there a technical reason this has to be the case, or is it arbitrary? If the former it might still be nice to switch them to anchors at some point, because not everyone will know that they can middle click to get a new tab. Not a big deal though.

  4. alexwl commented on Mar 31, 2019

    @alexwl
    Owner

    not everyone will know that they can middle click to get a new tab

    I agree. Middle mouse click on an identifier is a rather obscure feature. I'll think about adding a JavaScript context menu (which opens with a right click on an identifier) with an "Open in new tab" button.

    Is there a technical reason this has to be the case, or is it arbitrary?

    It is mostly for convenience. Each token (clickable and non-clickable) in the source code is just a span.

    There is no technical reason why Haskell identifiers can't be anchors.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions