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

Actually show glyphs for latex or emoji shortcodes being suggested in the REPL #54800

Merged

Conversation

jkrumbiegel
Copy link
Contributor

When a user requests a completion for a backslash shortcode, this PR adds the glyphs for all the suggestions to the output. This makes it much easier to find the result one is looking for, especially if the user doesn't know all latex and emoji specifiers by heart.

Before:

image

After:

image

@giordano giordano added REPL Julia's REPL (Read Eval Print Loop) 😃🍕 and other emoji labels Jun 14, 2024
@jkrumbiegel
Copy link
Contributor Author

I think the implementation is not quite right yet, it's probably not allowed/expected to have the completion start differently than what is being completed. Then you get this weird behavior once the list is narrowed down to one element:

Screen.Recording.2024-06-14.at.15.52.17.mov

Would appreciate if someone in the know could comment what other mechanism should be used instead.

@Keno
Copy link
Member

Keno commented Jun 14, 2024

You'll need to tweak the assumption that the completion being disabled and the text to be inserted are always the name. Probably the easiest way to do that is to pull the array of completions one level higher into complete_line(s::PromptState, repeats::Int, mod::Module) and add split the completion_text generic function into display and replacement completion texts.

@jkrumbiegel
Copy link
Contributor Author

I've introduced a NamedCompletion struct which for most of the existing functionality just stores the same string for name and completion. Just for backslash completions, these are different. The wacky behavior from before is gone with this change:

fix.mov.mp4

@jkrumbiegel
Copy link
Contributor Author

Looks like CI fails because an extension of Pkg uses REPL.REPLCompletions.completion_text which I changed. It was exported from that submodule but I'm not sure if it was intended to be public API of REPL or not. Could someone comment on that?

@Keno
Copy link
Member

Keno commented Jul 16, 2024

The use in Pkg predates them being separate packages. In general, REPL does not have a public API. Either way to fix this is fine (providing a fallback for the old code or fixing Pkg at the same time).

@jkrumbiegel
Copy link
Contributor Author

Finally returned to this PR..

I've reverted some of the changes that made the Pkg extension fail, this makes the code a little uglier due to the handling of two tuple types for complete_line, but as I don't know how to coordinate synchronized changes to Julia and Pkg I think it's easier to get a working version in first, then potentially refactor Pkg later if that's desired. But it might as well be that other people hooked into this functionality so while it's not public we don't have to break it, which is an advantage of the current changes.

It doesn't seem to me like the two build failures on CI are related to my changes, tests seem to pass otherwise.

@DilumAluthge
Copy link
Member

@IanButterworth Would you be able to review this PR?

@jkrumbiegel
Copy link
Contributor Author

Bump :)

@DilumAluthge
Copy link
Member

Bump @IanButterworth Would you be able to review this?

@IanButterworth
Copy link
Member

Sorry I'm not very familiar with this code. Perhaps the blame would show someone better suited?

@DilumAluthge DilumAluthge removed the request for review from IanButterworth December 3, 2024 02:33
@DilumAluthge
Copy link
Member

From looking at the git blame, maybe @Keno or @rfourquet?

@DilumAluthge
Copy link
Member

Thank you Keno!!

@DilumAluthge DilumAluthge merged commit 9acf112 into JuliaLang:master Dec 3, 2024
7 checks passed
@DilumAluthge DilumAluthge removed the request for review from rfourquet December 3, 2024 07:45
LilithHafner pushed a commit that referenced this pull request Dec 7, 2024
Show glyphs for latex or emoji shortcodes being suggested in the REPL
stevengj pushed a commit that referenced this pull request Jan 2, 2025
… the REPL (#54800)

When a user requests a completion for a backslash shortcode, this PR
adds the glyphs for all the suggestions to the output. This makes it
much easier to find the result one is looking for, especially if the
user doesn't know all latex and emoji specifiers by heart.

Before:

<img width="813" alt="image"
src="https://github.com/JuliaLang/julia/assets/22495855/bf651399-85a6-4677-abdc-c66a104e3b89">

After:

<img width="977" alt="image"
src="https://github.com/JuliaLang/julia/assets/22495855/04c53ea2-318f-4888-96eb-0215b49c10f3">

---------

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
stevengj pushed a commit that referenced this pull request Jan 2, 2025
Show glyphs for latex or emoji shortcodes being suggested in the REPL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😃🍕 and other emoji REPL Julia's REPL (Read Eval Print Loop)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants