File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
cursorless-everywhere-talon Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 2121class Actions :
2222 def cursorless_everywhere_get_editor_state () -> EditorState :
2323 command = {"type" : "getActiveEditor" }
24- return actions .user .run_rpc_command_get (RPC_COMMAND , command )
24+ res = rpc_get (command )
25+ if use_fallback (res ):
26+ return actions .next ()
27+ return res
2528
2629 def cursorless_everywhere_set_selections (
2730 selections : list [SelectionOffsets ], # pyright: ignore [reportGeneralTypeIssues]
@@ -30,13 +33,25 @@ def cursorless_everywhere_set_selections(
3033 "type" : "setSelections" ,
3134 "selections" : get_serializable_selections (selections ),
3235 }
33- actions .user .run_rpc_command_and_wait (RPC_COMMAND , command )
36+ res = rpc_get (command )
37+ if use_fallback (res ):
38+ actions .next (selections )
3439
3540 def cursorless_everywhere_edit_text (
3641 edit : EditorEdit , # pyright: ignore [reportGeneralTypeIssues]
3742 ):
3843 command = {"type" : "setText" , "text" : edit ["text" ]}
39- actions .user .run_rpc_command_and_wait (RPC_COMMAND , command )
44+ res = rpc_get (command )
45+ if use_fallback (res ):
46+ actions .next (edit )
47+
48+
49+ def rpc_get (command : dict ):
50+ return actions .user .run_rpc_command_get (RPC_COMMAND , command )
51+
52+
53+ def use_fallback (result : dict ) -> bool :
54+ return result .get ("fallback" , False )
4055
4156
4257# What is passed from cursorless everywhere js is a javascript object, which is not serializable for python.
You can’t perform that action at this time.
0 commit comments