Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please detail the need for resolve() #69

Closed
kenchris opened this issue Jun 27, 2019 · 6 comments · Fixed by #206
Closed

Please detail the need for resolve() #69

kenchris opened this issue Jun 27, 2019 · 6 comments · Fixed by #206

Comments

@kenchris
Copy link

kenchris commented Jun 27, 2019

In response to w3ctag/design-reviews#390

I don't really understand the need for resolve so can you add more info for that and maybe show example showing it value

@pwnall
Copy link
Collaborator

pwnall commented Jul 19, 2019

Given an IDE-like application, where a user is working on a project rooted in a directory, being able to resolve a handle lets the application show a file's location within the project. The information can be used to focus a directory tree view on the file, or to show the file's path in a title / status bar. This is needed when the file is obtained from a file picker, or (assuming changes to other specs) by dragging the file into the app, or from the OS's "Open with..." menu.

Does this use case help?

@guest271314
Copy link

@pwnall The use case does not appear to be clear from perspective here. Absolutely unclear at https://wicg.github.io/native-file-system/#dom-filesystemdirectoryhandle-resolve.

Is the expected usage let res = await dir.resolve(dir)?

Can you include a brief code snippet demonstrating the use case?

@pwnall
Copy link
Collaborator

pwnall commented Aug 7, 2019

This is probably broken, but I hope it gets the idea across.

// Called when the "Save As" button is clicked in an IDE.
async function onSaveAsClick() {
  const fileHandle = await self.chooseFileSystemEntries({type: 'openFile', readOnly: false});
  if (fileHandle === null) {
    // User canceled out of dialog, abandon the "Save As" intent.
    return;
  }
  
  // Get a directory handle to the root of the IDE's tree view.
  const treeRoot = workspace().treeView().rootHandle();

  const relativePath = treeRoot.resolve(fileHandle);
  if (relativePath === null) {
    // The selected file is outside the workspace.
    await workspace().treeView().hideCursor();
  } else {
    // Highlight the file selected from the picker in the IDE's tree view.
    await workspace().treeView().setCursor(relativePath);
  }

  // TODO: Write the current editor's buffer contents to fileHandle.
}

@guest271314
Copy link

Is the only application context an IDE which resolve() is used to "highlight" a path to a file? Still not following what resolve() is intended to achieve which is not possible using the values available from self.chooseFileSystemEntries()?

@mkruisselbrink
Copy link
Contributor

Without resolve() there is no way to compare different handles, so yes, IDE to highlight a path to a file is one option, another one would be launch events where when launching a PWA with a file that is already open might want to focus the window that has that file open rather than opening a new window.

So basically resolve() gives you a way to compare two handles and see if they are in any way related. Since we don't expose paths (or parents) in any way, there is no way to do these things with the rest of the API.

@foolip
Copy link
Member

foolip commented Nov 20, 2019

Looks like this was removed in commit 5e1146e, but it remains in EXPLAINER.md as await dir_ref.resolve(file_ref).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants