Skip to content

Commit 7e0c881

Browse files
committed
feat(repl): session-context toolbar + completion/popup polish
Adds the bottom-toolbar feature from the original plan plus the last round of UX polish on the prompt_toolkit candidate popup that we shaved down through testing: - **Bottom toolbar** shows the running RF version and the cwd at all times — orientation info that's useful when juggling several venvs / project directories. - **Esc** closes the candidate popup and reverts any preview text that arrow-navigation had pinned, restoring the user's literal pre-popup buffer. Bound only when the popup is open (`has_completions` filter) so Esc keeps its Alt-chord prefix role everywhere else. - **Enter** on a highlighted candidate accepts it (popup closes, preview becomes permanent). For keyword completions Enter also cleans up the cell — deletes any leftover text after the cursor in the same cell (so a mid-cell completion replaces the whole keyword) and appends a cell separator if no argument follows. - **Tab** is smart: cycles through the popup when one is open, inserts a cell separator in argument context, opens the popup otherwise. - **Multi-line history** survives a session restart as one entry (newlines are escaped to `\\n` on disk so the file stays readline-compatible). - **Mid-keyword preview** renders cleanly — `${Lo}` cursor before `o`, picking `Log To Console` now shows `Log To Console`, not `Log To Consoleog` (we trim the forward-cell tail from the state's `original_document` before prompt_toolkit applies the preview). - **TEXT_FRAGMENT** in compound variable lookups (`${PREFIX_${X}}`) renders with the variable-name colour, not the argument colour, so the eye reads the whole concatenated name as one identifier. - **EOL / EOS** tokens from Robot's tokenizer are dropped from the rendered fragments — `\\n` inside a fragment would otherwise show as `^J` at the end of every multi-line buffer line. - **Trailing whitespace** is padded out to the document's actual length so the cursor stays in sync with the buffer (was sticking at column 0 when the user kept typing spaces). - **`_completion.py`** is consolidated — `candidates_for()` is now a thin projection over `candidates_for_rich()`, ~200 lines of duplicated helpers removed (was an artefact of how the rich variant was added in the previous commit). - **`CELL_SEPARATOR`** + **`find_cell_end()`** added to `_completion.py` as named constants and a shared helper, used by the smart-Tab / Enter-cleanup paths.
1 parent c891215 commit 7e0c881

6 files changed

Lines changed: 777 additions & 302 deletions

File tree

docs/03_reference/repl.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ The completer runs in a background thread (`complete_in_thread=True`), and Robot
166166

167167
History is shared with the readline backend — same plain-text file, so swapping between the two extras (or having neither) doesn't lose arrow-up recall.
168168

169+
#### Session-context bottom toolbar
170+
171+
A status line at the bottom of the prompt shows two pieces of orientation info at a glance:
172+
173+
```
174+
RF 7.4 · cwd: ~/projects/my-suite
175+
```
176+
177+
- **RF version** — which Robot Framework is actually running (handy when juggling several venvs).
178+
- **Working directory** — where relative paths in `Import Resource`, `Import Library`, and file-based variables resolve from.
179+
169180
#### Documentation hints in the popup
170181

171182
Each candidate in the completion popup now shows a short context string to its right (prompt-toolkit's `display_meta`), so you know *what* a candidate is before picking it:

0 commit comments

Comments
 (0)