Skip to content
Myr

:hidden property of previous --preview-window should be cleared

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #636. Patch suggested by @edi9999.

authored by Junegunn Choi · committed by Junegunn Choi · parent 7cef92f · Browse files · 2 files+36 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+36 added−7 removed

  • other:+36 added−7 removed

2 files+36 added−7 removed

modified:src/options_test.go+35 added-7 removed
350 unmodified lines
351 check([]string{hist, "--bind=ctrl-p:accept"}, curses.CtrlN, actNextHistory)352 check([]string{hist, "--bind=ctrl-p:accept"}, curses.CtrlP, actAccept)353}354355func TestToggle(t *testing.T) {356 optsFor := func(words ...string) *Options {357 opts := defaultOptions()358 parseOptions(opts, words)359 postProcessOptions(opts)360 return opts361 }355func optsFor(words ...string) *Options {356 opts := defaultOptions()357 parseOptions(opts, words)358 postProcessOptions(opts)359 return opts360}361362func TestToggle(t *testing.T) {363 opts := optsFor()364 if opts.ToggleSort {365 t.Error()366 }
7 unmodified lines
374 if opts.ToggleSort {375 t.Error()376 }377}378379func TestPreviewOpts(t *testing.T) {380 opts := optsFor()381 if !(opts.Preview.command == "" &&382 opts.Preview.hidden == false &&383 opts.Preview.position == posRight &&384 opts.Preview.size.percent == true &&385 opts.Preview.size.size == 50) {386 t.Error()387 }388 opts = optsFor("--preview", "cat {}", "--preview-window=left:15:hidden")389 if !(opts.Preview.command == "cat {}" &&390 opts.Preview.hidden == true &&391 opts.Preview.position == posLeft &&392 opts.Preview.size.percent == false &&393 opts.Preview.size.size == 15+2) {394 t.Error(opts.Preview)395 }396397 opts = optsFor("--preview-window=left:15:hidden", "--preview-window=down")398 if !(opts.Preview.command == "" &&399 opts.Preview.hidden == false &&400 opts.Preview.position == posDown &&401 opts.Preview.size.percent == true &&402 opts.Preview.size.size == 50) {403 t.Error(opts.Preview)404 }405}
modified:src/options.go+1 added
722 unmodified lines
723}724725func parsePreviewWindow(opts *previewOpts, input string) {726 layout := input727 opts.hidden = false728 if strings.HasSuffix(layout, ":hidden") {729 opts.hidden = true730 layout = strings.TrimSuffix(layout, ":hidden")731 }
356 unmodified lines