Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

## [Unreleased]

### Added

- Pressing `n` in the picker unchecks every row, so you can start from an empty selection and check only what you want. `a` still toggles between all and none.

## [1.4.0] - 2026-11-17

### Added
Expand Down
62 changes: 62 additions & 0 deletions acceptance_tests/harness/steps_terminal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,68 @@ func theRowShouldBeChecked(ctx context.Context, relPath string) error {
return nil
}

// thatIHaveUncheckedTheRowFor toggles relPath's checkbox off and waits until the
// picker shows it clear, so the next key can't overtake the redraw.
func thatIHaveUncheckedTheRowFor(ctx context.Context, relPath string) error {
err := iPressOnTheRowFor(ctx, "space", relPath)
if err != nil {
return err
}
session, err := runningTerminal(ctx)
if err != nil {
return err
}
_, err = session.waitFor("the row for "+relPath+" unchecked", func(s TerminalScreen) bool {
index := s.RowIndex(relPath)
return index >= 0 && !s.Rows[index].Checked
})
return err
}

// theRowShouldNotBeChecked asserts relPath's checkbox is clear.
func theRowShouldNotBeChecked(ctx context.Context, relPath string) error {
screen, err := settledPicker(ctx)
if err != nil {
return err
}
index := screen.RowIndex(relPath)
if index < 0 {
return fmt.Errorf("no row for %s; screen was:\n%s", relPath, screen)
}
if screen.Rows[index].Checked {
return fmt.Errorf("row for %s is checked; screen was:\n%s", relPath, screen)
}
return nil
}

// noRowShouldBeChecked asserts every checkbox in the picker is clear.
func noRowShouldBeChecked(ctx context.Context) error {
screen, err := settledPicker(ctx)
if err != nil {
return err
}
for _, row := range screen.Rows {
if row.Checked {
return fmt.Errorf("row for %s is checked; screen was:\n%s", row.Path, screen)
}
}
return nil
}

// settledPicker returns the screen once the picker's rows are drawn and csync has
// stopped redrawing, so a check of the checkboxes can't read a frame mid-update.
func settledPicker(ctx context.Context) (TerminalScreen, error) {
session, err := runningTerminal(ctx)
if err != nil {
return TerminalScreen{}, err
}
_, err = session.waitFor("the picker's rows", func(s TerminalScreen) bool { return len(s.Rows) > 0 })
if err != nil {
return TerminalScreen{}, err
}
return session.settle()
}

// csyncShouldHaveExited asserts the process ended, as opposed to only leaving no sign
// of itself on screen.
func csyncShouldHaveExited(ctx context.Context) error {
Expand Down
3 changes: 3 additions & 0 deletions acceptance_tests/harness/steps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^the diff overlay should still be open$`, theDiffOverlayShouldStillBeOpen)
ctx.Step(`^no files should have been transferred$`, noFilesShouldHaveBeenTransferred)
ctx.Step(`^the row for "([^"]*)" should be checked$`, theRowShouldBeChecked)
ctx.Step(`^the row for "([^"]*)" should not be checked$`, theRowShouldNotBeChecked)
ctx.Step(`^no row should be checked$`, noRowShouldBeChecked)
ctx.Step(`^that I have unchecked the row for "([^"]*)"$`, thatIHaveUncheckedTheRowFor)
ctx.Step(`^csync should have exited$`, csyncShouldHaveExited)
ctx.Step(`^the diff overlay should include:$`, theDiffOverlayShouldInclude)
ctx.Step(`^the diff overlay's title should read "([^"]*)"$`, theDiffOverlaysTitleShouldRead)
Expand Down
1 change: 1 addition & 0 deletions acceptance_tests/harness/terminal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var terminalKeys = map[string]string{
"down": "\x1b[B",
"enter": "\r",
"esc": "\x1b",
"n": "n",
"space": " ",
"up": "\x1b[A",
}
Expand Down
4 changes: 3 additions & 1 deletion acceptance_tests/show-file-diff.feature
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ Feature: Show a file's diff from the picker
| enter |
| space |
| a |
| n |
| d |

Scenario: Pressing "enter" in the diff transfers nothing
Expand All @@ -248,6 +249,7 @@ Feature: Show a file's diff from the picker
| key |
| space |
| a |
| n |

Scenario: Ctrl-C in the diff cancels the run
Given that the file "README.md" has been changed locally
Expand Down Expand Up @@ -312,7 +314,7 @@ Feature: Show a file's diff from the picker
Scenario: The picker's hint line leaves the diff to a line of its own
Given that the file "README.md" has been changed locally
When I run "csync ./project user@host:/project" in a terminal
Then the hint line should read "↑/↓ move · space toggle · a all/none · enter sync · ctrl-c cancel"
Then the hint line should read "↑/↓ move · space toggle · a/n all/none · enter sync · ctrl-c cancel"

Scenario: The diff hint says which files can be diffed
Given that the file "README.md" has been changed locally
Expand Down
2 changes: 2 additions & 0 deletions internal/view/picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ func (m pickerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Toggle the whole list: clear it if every row is checked, otherwise check
// every row.
m.sel.SetAll(!m.sel.AllChecked())
case "n":
m.sel.SetAll(false)
case "d":
var fetch tea.Cmd
m, fetch = m.pressDiff()
Expand Down
2 changes: 1 addition & 1 deletion internal/view/pickerview.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (m pickerModel) View() string {
out := []string{
"",
"? " + prompt.Render(pickerPrompt(len(m.actions))),
" " + dim.Render("↑/↓ move · space toggle · a all/none · enter sync · ctrl-c cancel"),
" " + dim.Render("↑/↓ move · space toggle · a/n all/none · enter sync · ctrl-c cancel"),
m.diffHintLine(),
}

Expand Down
Loading