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

A floating window for suggestions? #7

Closed
imWildCat opened this issue Dec 30, 2022 · 19 comments · Fixed by #31 or #33
Closed

A floating window for suggestions? #7

imWildCat opened this issue Dec 30, 2022 · 19 comments · Fixed by #31 or #33
Labels
enhancement New feature or request stale

Comments

@imWildCat
Copy link

Instead of adding contents in the editor for suggestions, could we use a macOS window for suggestions?

Code in the editor seems to be super disturbing.

@intitni intitni added the enhancement New feature or request label Jan 2, 2023
@intitni
Copy link
Owner

intitni commented Jan 2, 2023

I have been thinking about the same thing. Will probably give it a try after 0.5.0.

@ICULikeMac
Copy link

Great idea

@MrMage
Copy link

MrMage commented Feb 10, 2023

I've read the latest release notes and would welcome a floating window with suggestions. Personally, I would suggest placing the window below the current text cursor, similar to Xcode's own suggestions. As an alternative, if that would interfere too much with Xcode's own suggestions, to the bottom left or above the cursor could also be options.

@imWildCat
Copy link
Author

@MrMage exactly! Similar to that of Grammarly Mac

@MrMage
Copy link

MrMage commented Feb 10, 2023

@imWildCat do you have a screenshot of that overlay for illustration? :-)

@imWildCat
Copy link
Author

https://www.grammarly.com/desktop/mac

@ICULikeMac
Copy link

Great idea referencing the Grammarly pop up. That would work here for sure! +1.

Note: I know sometimes the suggestions are quite large, unlike what's suggested in Grammarly but I don't think that's a problem as it's either filling up space on the page under the box or contained in a clean separate box which can be accepted/rejected.

@intitni
Copy link
Owner

intitni commented Feb 23, 2023

I think I'll try the Grammarly-like solution first, as it appears easier to implement to me. If we still want the below-cursor solution later, it shouldn't be too hard to make the switch, since the only difference is where the window is located.

@imWildCat
Copy link
Author

Thanks man! I believe even any floating window that is draggable is good! No need to be perfect at the initial stage.

Feel free to split tasks or create GH items for known issues and ask the community to fix.

@intitni
Copy link
Owner

intitni commented Mar 3, 2023

The first version is released in 0.8.1!

During development, I found that it's difficult to implement a suggestion window that follows the text cursor. The biggest problem is that we don't have a way to listen to the appearance and disappearance of Xcode's built-in completion panel. If we want to avoid overlapping with it, we would have to place the suggestion window in a strange position. Therefore, I think the current solution is better.

@intitni intitni pinned this issue Mar 3, 2023
@ICULikeMac
Copy link

Wow how cool! Looks fantastic - looking forward to using it this week!!

@imWildCat
Copy link
Author

@intitni this is huge! Thank you!

@mickael-menu
Copy link

The biggest problem is that we don't have a way to listen to the appearance and disappearance of Xcode's built-in completion panel.

I had a similar need for my plugin embedding NeoVim in Xcode. I found a workaround by:

  • Observing the AX created event.
  • For each AXUIElement received with created, check whether it contains a child (kAXChildrenAttribute) with an identifier (kAXIdentifierAttribute) of _XC_COMPLETION_TABLE_.
  • Observing uiElementDestroyed to know when the pop-up is closed.

You can find the code here.

Hope that helps, thank you for your work on this plugin!

@intitni
Copy link
Owner

intitni commented Mar 4, 2023

The biggest problem is that we don't have a way to listen to the appearance and disappearance of Xcode's built-in completion panel.

I had a similar need for my plugin embedding NeoVim in Xcode. I found a workaround by:

  • Observing the AX created event.
  • For each AXUIElement received with created, check whether it contains a child (kAXChildrenAttribute) with an identifier (kAXIdentifierAttribute) of _XC_COMPLETION_TABLE_.
  • Observing uiElementDestroyed to know when the pop-up is closed.

You can find the code here.

Hope that helps, thank you for your work on this plugin!

Based on my observation, the _XC_COMPLETION_TABLE_ does not get destroyed even if I close it with the ESC key until I either move the text cursor or exit the window. Is this also what you have experienced?

@mickael-menu
Copy link

No I get the destroyed event, otherwise that would break some keys in ShadowVim. Both when accepting a completion item or using escape.

I've tested only on Xcode 14.2 though.

@mickael-menu
Copy link

Oh, and I added the created and uiElementDestroyed observers on the app's AXUIElement.

@MaksimBezdrobnoi
Copy link

Awesome update with floating window! It gave me a second chance to use Copilot! thanks)

@intitni intitni unpinned this issue Mar 25, 2023
@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 16, 2023
@github-actions
Copy link

github-actions bot commented May 1, 2023

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
6 participants