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

Customizable timeout for clip.capture in selected_text #1210

Closed
phillco opened this issue May 28, 2023 · 1 comment · Fixed by #1517
Closed

Customizable timeout for clip.capture in selected_text #1210

phillco opened this issue May 28, 2023 · 1 comment · Fixed by #1517
Assignees

Comments

@phillco
Copy link
Collaborator

phillco commented May 28, 2023

@AndreasArvidsson pointed this out during the Cursorless session today, but clip.capture() has a default timeout of 500ms. This timeout is hit whenever the selection is empty.

This means that commands like "google that" are normally fast when used normally (with a selection), but if you don't have a selection (such as if they are triggered accidentally), you have to wait for this timeout. 500ms feels relatively high.

We theorized that this is to handle sluggish apps or sluggish computers, so this might be a reasonable default to keep, but we should make it a setting so that power users can lower the timeout (under the assumption that they would notice if they have an application that needs a higher timeout), and thus have a better experience.

Here's an example of setting 100ms, although we would obviously use a setting:

@ctx.action_class("edit")
class EditActions:
    def selected_text() -> str:
        with clip.capture(timeout=0.1) as s:
            actions.edit.copy()
        try:
            return s.text()
        except clip.NoChange:
            return ""
@AndreasArvidsson
Copy link
Collaborator

For what is worth I have now been using 0.1 for over a year without any problems. I'm definitely for reducing the default and adding a setting.

@AndreasArvidsson AndreasArvidsson self-assigned this Jul 30, 2024
@nriley nriley closed this as completed in 2d2ddeb Aug 3, 2024
MartinRykfors added a commit to MartinRykfors/knausj_talon that referenced this issue Sep 19, 2024
The default time out for `clip.capture()` is 0.5s. You run into this
every time you call `selected_text()` on an empty selection. I've been
running with 0.1 for over a year with no problems. That might be a bit
to aggressive for community, but 0.25 shouldn't be any problems. Just in
case I added a setting so people with slower (or faster) machines can
change this.

Fixes talonhub#1210
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 a pull request may close this issue.

2 participants