-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Turn hats off by default; add 'play' hat #80
Conversation
c4264ba
to
88667d8
Compare
def init_csv_and_watch_changes( | ||
filename: str, | ||
default_values: dict[str, dict], | ||
extra_acceptable_values: list[str] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the extra_acceptable_values
makes it so we don't complain if they have customized the name of a style that they're not currently using
"-frame": "frame", | ||
"-curve": "curve", | ||
"-stare": "eye", | ||
"ex": "ex", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we leave them all on by default, but they get filtered if they're not active
def on_ready(): | ||
init_csv_and_watch_changes( | ||
"special_marks", | ||
DEFAULT_COLOR_ENABLEMENT = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know not great to hardcode this stuff. But we won't need to once we do it using the new state sharing stuff so I think this is ok for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndreasArvidsson Ok so one problem with this hard coding is that if we turn some shapes on by default extension side, we would have to update this code and then there would be mismatch until they update talon side
We could maybe have cursorless extension write default enablement to json in post-install script?
src/marks/mark.py
Outdated
|
||
def on_watch(path, flags): | ||
if vscode_settings_path.match(path): | ||
cron.after("500ms", setup_hat_styles_csv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was getting some weird race conditions with fs.watch
where I'd see the old value sometimes
src/marks/vscode_settings.py
Outdated
@@ -0,0 +1,58 @@ | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should prob make its way into knausj at some point, but for now leaving it here
@@ -0,0 +1,137 @@ | |||
# From https://github.com/linjackson78/jstyleson/blob/8c47cc9e665b3b1744cccfaa7a650de5f3c575dd/jstyleson.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vendoring this one because it's painful to pip install stuff. Small file so I don't think it's a big deal. We use this for parsing jsonc
btw @AndreasArvidsson one thing I think is nice about this approach is that if they never enable a shape, it never appears in their overrides csv, so if we change the default name later they'll get the latest one when they enable the shape |
@@ -16,7 +16,7 @@ | |||
"<user.cursorless_target> [{user.cursorless_source_destination_connective} <user.cursorless_target>]" | |||
) | |||
) | |||
def cursorless_move_bring_targets(m) -> str: | |||
def cursorless_move_bring_targets(m) -> list[dict]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
talon seems to have gotten stricter about type checking so this one was causing errors; seemed small enough to tack onto this PR
targets: list[dict], | ||
arg1: any = NotSet, | ||
arg2: any = NotSet, | ||
arg3: any = NotSet, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moving to the new generics
src/marks/mark.py
Outdated
|
||
def on_watch(path, flags): | ||
if vscode_settings_path.match(path): | ||
cron.after("1s", setup_hat_styles_csv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in love with this sleep but seems to make things pretty robust on my computer and I don't think the delay is a big deal
def pick_path(paths: list[Path]): | ||
existing_paths = [path for path in paths if path.exists()] | ||
return max(existing_paths, key=lambda path: path.stat().st_mtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the recency logic we were talking about
src/read_json_with_timeout.py
Outdated
@@ -0,0 +1,50 @@ | |||
import json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just copied from command server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and is working fine for me now. The whole issue that the settings file could be in a different location is still a problem of course.
This reverts commit 1e05019.
Closes #79