Repository navigation
Conversation
b2b3610 to
78b2bf2
Compare
✅ Integration test reportCommit: c254801
Top 41 slowest tests (at least 2 minutes):
|
|
/review |
| } | ||
|
|
||
| case tea.KeyMsg: | ||
| if in, ok := teainput.Decode(msg); ok { |
There was a problem hiding this comment.
The select model (line 256) and pager (line 186) both guard against paste before dispatching, but the table view doesn't. In normal mode a paste event has in.Key == "", so the updateNormal switch falls through and m.viewport.Update(msg) receives the raw tea.KeyMsg. If the viewport has a key binding that matches the pasted text (e.g. a single pasted "d" hitting HalfPageDown), it would scroll. Can we add a paste guard here like the other two models?
78b2bf2 to
94fea4a
Compare
94fea4a to
558222b
Compare
558222b to
c254801
Compare
|
/review |
There was a problem hiding this comment.
Automated review at c254801. Each finding was verified against the code.
Not ready yet: part of the automated review did not complete.
This PR makes Alt+non-letter keys inert across prompts, selection lists, the pager and the table view, and routes paste as literal text rather than as individual key presses. The decoder change (teainput.go) and consumer updates are consistent with each other. Two minor gaps remain in the tableview: paste in normal mode isn't intercepted (unlike the select model), and backspace in search still truncates a byte rather than a rune.
Comments outside the changed lines
- [nice to have]
libs/tableview/tableview.go:338: The select model usesutf8.DecodeLastRuneInStringfor backspace (select.go:298), butupdateSearchtruncates one byte. Now that line 343 feedsin.Text(including paste) intosearchInput, a multi-byte character likeéfollowed by backspace leaves an invalid UTF-8 fragment. Consider matching the select model's pattern:
if _, size := utf8.DecodeLastRuneInString(m.searchInput); size > 0 {
m.searchInput = m.searchInput[:len(m.searchInput)-size]
}| return m.updateSearch(in) | ||
| } | ||
| return m.updateNormal(msg) | ||
| return m.updateNormal(msg, in.Key) |
There was a problem hiding this comment.
[nice to have] A paste in normal mode has in.Key == "", so updateNormal matches no case and the raw tea.KeyMsg (with Paste: true) is forwarded to m.viewport.Update(msg) at line 290. The select model intercepts paste before the key switch (select.go:256–262); the same guard here would keep the two models consistent and avoid leaking a decoded event back into an undecoded path. Something like:
if in, ok := teainput.Decode(msg); ok {
if in.Paste {
if m.searching && in.Text != "" {
m.searchInput += in.Text
}
return m, nil
}
...
}…paste as text These are the deliberate v1 behaviour changes, each with its golden rows: - Alt stays in the key name for every non-rune key, so Alt+Enter, Alt+arrows, Alt+Ctrl+C and Alt+Space match no case and do nothing in prompts, selection lists and the pager. v1 acted as the plain key, because it ignored Alt on those keys. Goldens: TestKeysPin_PromptAltEnter, TestKeysPin_PromptAltLeft, TestKeysPin_SelectAltEnter. - A paste in a selection list is literal search text when search is open and is ignored otherwise. v1 treated a paste like typed keys, so a pasted "j" moved the cursor and a pasted "/" opened search. Pinned by TestSelectPaste. - The table view's search takes Text, not msg.String(). v1 appended "alt+f" for Alt+F and "[text]" for a paste. Goldens: TestTableviewPin_SearchInput (search input and status line now read "match 1/10"). Changelog: .nextchanges/cli/alt-keys-inert.md. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
c254801 to
21cecc5
Compare
Changes
These are the deliberate v1 behaviour changes, each with its golden rows:
TestKeysPin_PromptAltEnter(typedabc, not submitted),TestKeysPin_PromptAltLeft(abcX),TestKeysPin_SelectAltEnter(the list stays on screen and a later Enter picksid-02).jmoved the cursor and a pasted/opened search. Unit test:TestSelectPaste.alt+ffor Alt+F and[text]for a paste. Golden:TestTableviewPin_SearchInput(search readsitem-1; status readsmatch 1/10).Changelog:
.nextchanges/cli/alt-keys-inert.md.Why
Alt+Enter submitting a prompt and Alt+Left moving the cursor were v1 side effects of ignoring Alt, not designed behaviour. No standard gives those keys a meaning, and on macOS Option sends Meta only with "Option as Meta". Making them inert also keeps the v2 key names unambiguous for the v2 swap.
Tests
go build ./..., golangci-lint (0 issues), gofmt clean.TERM=xterm-256color go test -race -count=3 ./libs/cmdio/... ./libs/tableview/...passes.TestKeysPin_PromptAltEnter/{01-after-alt-enter,02-result}:Value: abbecomes✔ Value: abc█.TestKeysPin_PromptAltLeft/{01-after-alt-left,02-result}:abXcbecomesabcX.TestKeysPin_SelectAltEnter/01-after-alt-enter: the list stays on screen.TestTableviewPin_SearchInput/{02-search-input,03-after-search.styled}:/ italt+f[em-1]█becomes/ item-1█;no matchesbecomesmatch 1/10.-update.go test ./acceptance/...) passes.Stack: based on
pietern/charm-v2/03b-teainput.Manual checks for real terminals:
databricks selftest tui prompt, typeab, Alt+Enter,c, Enter:Entered: abc(v1:Entered: ab).databricks selftest tui select --n 3, Alt+Enter: nothing happens; Enter selects the highlighted item.databricks selftest tui table --rows 50:/, Alt+F, then type: the search text has noalt+f.This pull request and its description were written by Isaac.