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

Be nicer about where to open the results webview #1037

Merged
merged 5 commits into from
Dec 15, 2021

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Dec 7, 2021

Currently, the webview always opens next to the currently active
editor. This is a pain if you already have 2 columns open since this
means that the webview will open in a third column, which is rarely
what you want.

This change uses a more sophisticated approach to opening the webview:

  1. If there is only one column, open webview to the right of it
  2. If there are multiple columns and the active editor is not the
    last column, open to the right of the active editor
  3. Otherwise open in the first column.

This will avoid opening a new column unless there is only one column
open right now.

There is no native API that vscode exposed to compare column locations,
so this uses the ViewColumn api is a slightly non-standard way.

A limitation is that if the last column is empty and the active editor
is to the left of it, then the webview will not be opened there (which
would be nice). Instead, it will be opened in column 1.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • @github/docs-content-codeql has been cc'd in all issues for UI or other user-facing changes made by this pull request.

@aeisenberg aeisenberg requested a review from a team as a code owner December 7, 2021 02:03
Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure how to review the actual code, but I tried opening webviews in various locations locally, and that worked as expected! 🕸️

Could you add a changelog entry for this PR?

extensions/ql-vscode/src/interface.ts Outdated Show resolved Hide resolved
Currently, the webview _always_ opens next to the currently active
editor. This is a pain if you already have 2 columns open since this
means that the webview will open in a third column, which is rarely
what you want.

This change uses a more sophisticated approach to opening the webview:

1. If there is only one column, open webview to the right of it
2. If there are multiple columns and the active editor is _not_ the
   last column, open to the right of the active editor
3. Otherwise open in the first column.

This will avoid opening a new column unless there is only one column
open right now.

There is no native API that vscode exposed to compare column locations,
so this uses the `ViewColumn` api is a slightly non-standard way.

A limitation is that if the last column is empty and the active editor
is to the left of it, then the webview will not be opened there (which
would be nice). Instead, it will be opened in column 1.
@aeisenberg
Copy link
Contributor Author

@shati-patel can I get another look at this one?

Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops sorry, I completely forgot to approve this 🙈

Thanks for the ping!!!

extensions/ql-vscode/CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Shati Patel <[email protected]>
@aeisenberg aeisenberg enabled auto-merge (squash) December 15, 2021 19:27
@aeisenberg aeisenberg merged commit 6e2e72a into main Dec 15, 2021
@aeisenberg aeisenberg deleted the aeisenberg/view-column branch December 15, 2021 19:33
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.

2 participants