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

Fix: prevent freezing of autocomplete in Zsh #105

Merged
merged 1 commit into from
Aug 20, 2023

Conversation

turboBasic
Copy link
Contributor

@turboBasic turboBasic commented Aug 14, 2023

Collects all pages using single invocation of base name instead of invoking basename for all individual page

What does it do?

Replaces multiple (now 2400+) invocations of basename with the single one.

Why the change?

Change prevents freezing of console when user presses <TAB> by dramatically decreasing time to lookup page files:

Before:

❯ time find $HOME/.tldrc/tldr/pages/common -name '*.md' -exec basename {} .md \; >/dev/null                                      
find $HOME/.tldrc/tldr/pages/common -name '*.md' -exec basename {} .md \; >   1.51s user 3.58s system 36% cpu 14.076 total

After:

❯ time find $HOME/.tldrc/tldr/pages/common -name '*.md' -exec basename -s .md {} + >/dev/null                                    
find $HOME/.tldrc/tldr/pages/common -name '*.md' -exec basename -s .md {} + >  0.00s user 0.01s system 22% cpu 0.047 total

How can this be tested?

Change can be tested by invoking autocompletion in Zsh: enter tldr and press tab key.
Zsh autocomplete file should be sourced before testing: source autocomplete/complete.zsh

Where to start code review?

Single line change so it is self-explanatory

Relevant tickets?

None

Questions?

None

Collects all pages using single invocation of base name instead of
invoking basename for all individual page
Copy link
Member

@kbdharun kbdharun left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for your contribution ❤️ .

I too use Zsh, tested all your changes and got similar results. Now, the autocompletion is nearly instantaneous.

@kbdharun kbdharun changed the title Prevent freezing of autocomplete in Zsh Fix: prevent freezing of autocomplete in Zsh Aug 20, 2023
@kbdharun kbdharun merged commit 7c16e9a into tldr-pages:main Aug 20, 2023
4 checks passed
lakshayrohila added a commit to lakshayrohila/tldr-c-client that referenced this pull request Feb 15, 2024
@lakshayrohila lakshayrohila mentioned this pull request Feb 15, 2024
2 tasks
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.

None yet

2 participants