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

"show decompiled" / "show semanticdb" etc. and split view #1131

Open
kubukoz opened this issue Aug 28, 2022 · 4 comments
Open

"show decompiled" / "show semanticdb" etc. and split view #1131

kubukoz opened this issue Aug 28, 2022 · 4 comments
Labels

Comments

@kubukoz
Copy link

kubukoz commented Aug 28, 2022

Describe the bug

When using a split view, using a command like "Show decompiled with javap" or "show semanticdb" may use the unexpected file (as in, not the one you currently have a cursor on).

It seems like Metals has a heuristic for picking the file based on the last edit / last opened file. I assume this is because workspace/executeCommand doesn't provide the currently focused file (it's not a textDocument request, after all).

To Reproduce Steps to reproduce the behavior:

  1. Create a couple files in a workspace
  2. Open two or more of them in a split pane view
  3. Edit file A
  4. Focus on file B
  5. Ask metals to show semanticdb

Expected behavior

File B's semanticdb is shown

Screenshots

image

(make an edit in B)

image

(click on A, ask for semanticdb)

image

Installation:

  • Operating system: macOS
  • VSCode version: 1.70.2
  • VSCode extension version: 1.19.7
  • Metals version: 0.11.8+38-1832a3cf-SNAPSHOT

Additional context

Search terms

split pane, split view, executeCommand, command

@kubukoz
Copy link
Author

kubukoz commented Aug 28, 2022

I don't really know of a workaround except for a client-side registerTextEditorCommand - but I know it's a thing that'll have to be implemented by each language client.

A long-term solution would probably be to suggest adding a textDocument/executeCommand in LSP.

@kpodsiad
Copy link
Member

kpodsiad commented Aug 28, 2022

Current heuristic - find first matching editor (comment apparently lies)

// returns an active editor uri, fallbacks to currently active file
function uriWithFallback(): Uri | undefined {
if (uri) {
return uri;
} else {
// no uri supplied, search for current active file
const editor = window.visibleTextEditors.find(
(e) =>
isSupportedLanguage(e.document.languageId) ||
e.document.fileName.endsWith(decodeExtension)
);
return editor?.document.uri;
}
}

Simple workaround - show all matching editors and let user pick one with quickpick if there's more than one.

@kubukoz
Copy link
Author

kubukoz commented Aug 28, 2022

yeah, in the case of javap there's already a selection required (which class) - should there be another one or should it be a concatenation of each file's classes?

@kpodsiad
Copy link
Member

yeah, in the case of javap there's already a selection required (which class) - should there be another one or should it be a concatenation of each file's classes?

Similar mechanism, but this time on frontend will be needed. Server accepts pair (uri, "decompile" kind (tasty, semanticDB, javap)) and it shows quickpick for cases when there are more eligible classes in given file.

In this case, quickpick can be shown when there are more matching editors, but this can be done solely on the frontend side.

To Reproduce Steps to reproduce the behavior:

  1. Create a couple files in a workspace
  2. Open two or more of them in a split pane view
  3. Edit file A
  4. Focus on file B
  5. Ask metals to show semanticdb

BTW, I can't reproduce it, I'm always getting semanticDB view for currently focused file 🤔

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

No branches or pull requests

2 participants