diff options
| author | user <user@clank> | 2026-08-01 15:50:11 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-01 15:50:11 +0200 |
| commit | 6d87b75e7686875598ba49f4223d7e2be5a9e241 (patch) | |
| tree | f35300623dc291cd1b6c848bffade6570b6c934f /idatui/rpc.py | |
| parent | rpc: a navigation that timed out reported success and corrupted the next edit (diff) | |
| download | ida-tui-6d87b75e7686875598ba49f4223d7e2be5a9e241.tar.gz ida-tui-6d87b75e7686875598ba49f4223d7e2be5a9e241.tar.xz ida-tui-6d87b75e7686875598ba49f4223d7e2be5a9e241.zip | |
rpc: comments are instant and newlines no longer vanish
Two fixes to the comment verb:
Drop the per-character typing delay. Rename/retype/goto use a 35 ms delay for
the visual effect (the agent's keystrokes appear one by one on the livestream),
but comments can be long — a 200-char annotation blocked the driver for 7 s of
pure animation. Comments now type instantly (delay=0); the aesthetic delay is
kept for rename, retype and goto where values are short.
Escape literal newlines before injecting into the prompt. The Input widget is
single-line, so a real 0x0a sent as a keystroke was silently swallowed. The
app's _do_comment already converts the two-char sequence '\\n' into a real
newline for IDA, so the RPC layer now does text.replace('\\n', '\\\\n')
before typing — both literal newlines from the caller and explicit \\n in the
text reach IDA as multi-line comments (each line gets its own // prefix in the
decompiler).
Verified on a live pane: a comment with an embedded newline now renders as two
// lines in the pseudocode, and long comments appear without the multi-second
typing pause.
tests/test_scenarios.py: 212 passed, 0 failed.
Diffstat (limited to 'idatui/rpc.py')
| -rw-r--r-- | idatui/rpc.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/idatui/rpc.py b/idatui/rpc.py index 8d90a1f..717f4df 100644 --- a/idatui/rpc.py +++ b/idatui/rpc.py @@ -59,7 +59,7 @@ METHODS = { "text": "{text,delay_ms?,settle?} type a literal string into the focused input", "goto/open": "{target,delay_ms?} g-prompt to a name or 0xADDR", "rename": "{name,word?,delay_ms?} rename the token under (or 'word') the cursor", - "comment": "{text,delay_ms?} comment the current line", + "comment": "{text} comment the current line (use \\n for newlines)", "retype": "{proto,word?,delay_ms?} set the prototype/type under the cursor", "follow": "{word?} follow the reference under (or 'word') the cursor", "cursor_on": "{word,line?,occurrence?=1} place the cursor on a token", @@ -746,7 +746,13 @@ class RpcServer: await settle(app, timeout=timeout) return snapshot(app) if method == "comment": - await self._fill_prompt("semicolon", "comment", str(params["text"]), delay, + # Comments can be long; skip the per-char delay so the agent isn't + # blocked for seconds watching the typing animation. Also: the + # prompt is single-line, so literal newlines (0x0a) get swallowed by + # the Input widget. The app's _do_comment converts the two-char + # sequence '\n' into a real newline for IDA, so we escape here. + ctext = str(params["text"]).replace("\n", "\\n") + await self._fill_prompt("semicolon", "comment", ctext, 0, clear=True) await settle(app, timeout=timeout) return snapshot(app) |
