Skip to content

feat: Include query text in history hover #307

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

Merged
merged 2 commits into from
Apr 20, 2020

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Mar 23, 2020

Include the text of the query file when hovering. For quick eval, only
show the selected text.

Long files are truncated in the hover. It looks like vscode limits tooltips to only a few hundred chars.

Not sure if showing the text for all queries makes sense. The other option is to only show expanded tooltips for quick eval.

@aeisenberg
Copy link
Contributor Author

Closes #264

@adityasharad
Copy link
Contributor

Thought: instead of showing it in the tooltip, could we have a right-click menu command for 'Show original query text', that displays the query text (at the time the query was run) in a temporary editor window? I imagine most query text is going to be too large to usefully view in tooltips (and they are not the most accessible part of the UI).
We would need to take some care to distinguish in the UI (and docs) between 'this is the query exactly at the time you ran it' vs 'this is the same query file you ran, but you may have changed it since it was run'.

@aeisenberg
Copy link
Contributor Author

Certainly something I can try, though it would be hard to visually distinguish the historical query text from a regular file.

I have another idea. We could show the query text in the results view itself. It could be placed in a text area that is hidden by default and there is a button somewhere that shows and hide it.

@aeisenberg
Copy link
Contributor Author

aeisenberg commented Mar 23, 2020

And perhaps, for quick eval (which tend to be shorter queries) we can still keep the text in the tooltip. And we can also show query text in the results view.

(we can include a disclaimer that this was the text when the query ran, but it may not coincide with the current text of the query file)

@jcreedcmu
Copy link
Contributor

In the current version, I'm not getting any hovertext for quick eval; I think showing the token being eval'ed would be useful to store, or having some mechanism to jump back to it.

@aeisenberg
Copy link
Contributor Author

I think showing the token being eval'ed would be useful to store,

Definitely

or having some mechanism to jump back to it.

Well, can't jump back to something if it no longer exists. We can only show it in an isolated, synthetic location.

@aeisenberg
Copy link
Contributor Author

On a deeper look, I think that @adityasharad 's idea of opening the query text in an editor is probably the best way to go. Vscode has a good API for creating read-only virtual documents. And we can stuff the contents in there. We can also possibly get syntax highlighting for free.

@aeisenberg aeisenberg force-pushed the aeisenberg/hover branch 2 times, most recently from 22114d3 to 355017d Compare March 24, 2020 21:30
@aeisenberg aeisenberg changed the title [RFC] feat: Include query text in history hover feat: Include query text in history hover Mar 24, 2020
@jcreedcmu
Copy link
Contributor

When I test what I believe to be its current state, this PR still includes full query text in the case of regular queries, which I'm not sure I'm convinced is a good idea, and doesn't seem to have any extra information in the case of quick-eval, which doesn't justify closing #264. Am I doing something wrong?

@aeisenberg
Copy link
Contributor Author

Yes, I kept the full text in for regular queries. Not sure if this works or not. Probably not necessary any more now that you can access the full text elsewhere.

As for extra information on quick eval. What extra information are you thinking of? The full context of the evaluation?

@aeisenberg
Copy link
Contributor Author

OK...I removed the query text on hover. Now, the hover behaviour is as it was. The way to see query text is to right click and select "Show Query Text" in the history actions. This will show the text of the file (or the selected quick eval text) in a read-only editor.

@aeisenberg
Copy link
Contributor Author

In terms of extra context that we store for quick eval queries. I'm not finding it in vscode objects. Can you point me to where it can be found?

@adityasharad
Copy link
Contributor

Perhaps just the position:

public readonly quickEvalPosition?: messages.Position,
or right next to where you added the quick-eval text in this PR.

@aeisenberg
Copy link
Contributor Author

From @jcreedcmu's comment earlier, I had assumed that the extra context describes the implicit bindings and types of the variables used in the query. The text position of the query is already available in the default hover on the history item.

Though, maybe I'm misunderstanding what's being asked for and what's available.

@jcreedcmu
Copy link
Contributor

Given that we have the position, we could extract the text at the time of querying and store that somewhere --- or store the location, and have a mechanism for jumping to that location from the context menu of the stored query, or something? I think we can tag treeview items with tags and condition what's in the context menu based on them.

@aeisenberg
Copy link
Contributor Author

That's mostly what this PR does. It adds a new context menu. Though, it's true that we could change the "Open Query" command so that it selects the text in the query (though this would be incorrect if the underlying text changes). It seems like this change would be part of a different PR, though.

Let's discuss on slack what exactly should be included here and what I should do for later.

jcreedcmu
jcreedcmu previously approved these changes Apr 17, 2020
@aeisenberg
Copy link
Contributor Author

Thanks for the approval @jcreedcmu. There was a misunderstanding on my part. It turns out that you can run a quick eval query by simply placing the caret in a particular location (with a selection length of 0). In this case, the query text being shown was an empty string.

In this situation, I made the change so that the entire line is shown, which I think is a reasonable compromise.

Ideally, we could reach into the query server and get detailed access about the quick eval query (eg- bound variables) but that is a task for another time.

Add new command to view the query text in a synthetic, read-only
document.

Quick eval queries will show the text selected when initially running
the query. Quick eval queries where the user has a single caret
selection will show the entire line of text.
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 this pull request may close these issues.

3 participants