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

Improve code context menu layout position esp visual stability #22102

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

mgsloan
Copy link
Contributor

@mgsloan mgsloan commented Dec 16, 2024

  • Now decides whether the menu is above or below the target position before rendering it. This causes its position to no longer vary depending on the length of completions

  • When the text area is height constrained (< 12) lines, now chooses the side which has the most space. Before it would always display above if height constrained below.

  • Misc code cleanups

Release Notes:

  • Improved completions menu layout to be more stable and use available space better.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 16, 2024
@mgsloan mgsloan force-pushed the code-context-menu-layout-stability branch 5 times, most recently from a0d69f2 to 454d24e Compare December 16, 2024 20:18
@@ -859,8 +891,10 @@ impl CodeActionsMenu {
},
)
.elevation_1(cx)
.p_1()
.max_h(max_height)
// x padding is the same as y.
Copy link
Member

Choose a reason for hiding this comment

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

We could use a single .p here:

Suggested change
// x padding is the same as y.
.p(Self::y_padding() / 2.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah true, thanks!! Ended up replacing this code with use of ListItem + Popover in #22112

@mgsloan mgsloan force-pushed the code-context-menu-layout-stability branch from 454d24e to 986890c Compare December 16, 2024 22:09
mgsloan added a commit that referenced this pull request Dec 16, 2024
This is good for code sharing but also sets up #22102 for making
assumptions about popover y padding.

Release Notes:

- N/A
@mgsloan mgsloan force-pushed the code-context-menu-layout-stability branch from 0e48dc9 to 2788636 Compare December 17, 2024 06:02
* Now decides whether the menu is above or below the target position
before rendering it. This causes its position to no longer vary
depending on the length of completions

* When the text area is height constrained (< 12) lines, now chooses
the side which has the most space. Before it would always display
above if height constrained below.

* Misc code cleanups
@mgsloan mgsloan force-pushed the code-context-menu-layout-stability branch from 2788636 to 04ec2b6 Compare December 17, 2024 06:04
@mgsloan mgsloan merged commit a062c0f into main Dec 17, 2024
9 checks passed
@mgsloan mgsloan deleted the code-context-menu-layout-stability branch December 17, 2024 06:17
mgsloan added a commit that referenced this pull request Dec 17, 2024
* Presence of the aside no longer affects position of the context menu.

* Prefers to fit to the right, then on same side of line, then other
side of line, within the following preference order:
  - Max possible size within text area.
  - Max possible size within window.
  - Actual size within window. This is the only case that could cause
    it to jump around with less stability.

A further enhancement atop this might be to dynamically resize aside height to fit.

Release notes are N/A as they are covered by the notes for #22102.

Closes #8523

Release notes:

* N/A
mgsloan added a commit that referenced this pull request Dec 18, 2024
* Presence of the aside no longer affects position or size of the
context menu.

* Prefers to fit to the right, then on same side of line, then other
side of line, within the following preference order:
  - Max possible size within text area.
  - Max possible size within window.
- Actual size within window. This is the only case that could cause it
to jump around with less stability.

A further enhancement atop this might be to dynamically resize aside
height to fit.

Release notes are N/A as they are covered by the notes for #22102.

Closes #8523

Release Notes:

* N/A
helgemahrt pushed a commit to helgemahrt/zed that referenced this pull request Dec 18, 2024
This is good for code sharing but also sets up zed-industries#22102 for making
assumptions about popover y padding.

Release Notes:

- N/A
helgemahrt pushed a commit to helgemahrt/zed that referenced this pull request Dec 18, 2024
…industries#22102)

* Now decides whether the menu is above or below the target position
before rendering it. This causes its position to no longer vary
depending on the length of completions

* When the text area is height constrained (< 12) lines, now chooses the
side which has the most space. Before it would always display above if
height constrained below.

* Misc code cleanups

Release Notes:

- Improved completions menu layout to be more stable and use available
space better.
helgemahrt pushed a commit to helgemahrt/zed that referenced this pull request Dec 18, 2024
)

* Presence of the aside no longer affects position or size of the
context menu.

* Prefers to fit to the right, then on same side of line, then other
side of line, within the following preference order:
  - Max possible size within text area.
  - Max possible size within window.
- Actual size within window. This is the only case that could cause it
to jump around with less stability.

A further enhancement atop this might be to dynamically resize aside
height to fit.

Release notes are N/A as they are covered by the notes for zed-industries#22102.

Closes zed-industries#8523

Release Notes:

* N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants