Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wrapping tree key #332

Merged
merged 2 commits into from
Jan 2, 2021
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
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PWD := ${CURDIR}
PRODUCTION_REGISTRY = docker.io
TEST_IMAGE = busybox:latest

all: clean build
all: gofmt clean build

## For CI

Expand Down Expand Up @@ -119,13 +119,13 @@ run-podman-large: build
run-ci: build
CI=true $(BUILD_PATH) dive-example:latest --ci-config .data/.dive-ci

build:
build: gofmt
go build -o $(BUILD_PATH)

generate-test-data:
docker build -t dive-test:latest -f .data/Dockerfile.test-image . && docker image save -o .data/test-docker-image.tar dive-test:latest && echo 'Exported test data!'

test:
test: gofmt
./.scripts/test-coverage.sh

dev:
Expand All @@ -135,4 +135,5 @@ clean:
rm -rf dist
go clean


gofmt:
go fmt -x ./...
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package cmd

import (
"fmt"
"github.com/wagoodman/dive/dive"
"github.com/wagoodman/dive/dive/filetree"
"io/ioutil"
"os"
"path"
"strings"

"github.com/wagoodman/dive/dive"
"github.com/wagoodman/dive/dive/filetree"

"github.com/mitchellh/go-homedir"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -90,6 +91,7 @@ func initConfig() {
viper.SetDefault("keybinding.toggle-removed-files", "ctrl+r")
viper.SetDefault("keybinding.toggle-modified-files", "ctrl+m")
viper.SetDefault("keybinding.toggle-unmodified-files", "ctrl+u")
viper.SetDefault("keybinding.toggle-wrap-tree", "ctrl+p")
viper.SetDefault("keybinding.page-up", "pgup")
viper.SetDefault("keybinding.page-down", "pgdn")

Expand Down
11 changes: 11 additions & 0 deletions runtime/ui/view/filetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func (v *FileTree) Setup(view *gocui.View, header *gocui.View) error {
IsSelected: func() bool { return v.vm.ShowAttributes },
Display: "Attributes",
},
{
ConfigKeys: []string{"keybinding.toggle-wrap-tree"},
OnAction: v.toggleWrapTree,
IsSelected: func() bool { return v.view.Wrap },
Display: "Wrap",
},
{
ConfigKeys: []string{"keybinding.page-up"},
OnAction: v.PageUp,
Expand Down Expand Up @@ -281,6 +287,11 @@ func (v *FileTree) toggleCollapseAll() error {
return v.Render()
}

func (v *FileTree) toggleWrapTree() error {
v.view.Wrap = !v.view.Wrap
return nil
}

func (v *FileTree) notifyOnViewOptionChangeListeners() error {
for _, listener := range v.listeners {
err := listener()
Expand Down