mirror of
https://github.com/arl/gitmux.git
synced 2026-09-10 07:26:18 -04:00
feat: add trailing space option
This commit is contained in:
parent
7139d16775
commit
0e8dbbaac2
|
|
@ -81,3 +81,5 @@ tmux:
|
|||
ellipsis: …
|
||||
# Hides the clean flag.
|
||||
hide_clean: false
|
||||
# Adds a trailing space to the layout.
|
||||
trailing_space: false
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ tmux:
|
|||
branch_trim: right
|
||||
ellipsis: …
|
||||
hide_clean: false
|
||||
trailing_space: false
|
||||
```
|
||||
|
||||
First, save the default configuration to a new file:
|
||||
|
|
@ -271,6 +272,7 @@ This is the list of additional configuration `options`:
|
|||
| `branch_trim` | Trim left or right end of the branch (`right` or `left`) | `right` (trailing) |
|
||||
| `ellipsis` | Character to show branch name has been truncated | `…` |
|
||||
| `hide_clean` | Hides the clean flag entirely | `false` |
|
||||
| `trailing_space` | Adds a trailing space to the layout | `false` |
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
|
|
|||
|
|
@ -85,10 +85,11 @@ func (d *direction) UnmarshalYAML(value *yaml.Node) error {
|
|||
}
|
||||
|
||||
type options struct {
|
||||
BranchMaxLen int `yaml:"branch_max_len"`
|
||||
BranchTrim direction `yaml:"branch_trim"`
|
||||
Ellipsis string `yaml:"ellipsis"`
|
||||
HideClean bool `yaml:"hide_clean"`
|
||||
BranchMaxLen int `yaml:"branch_max_len"`
|
||||
BranchTrim direction `yaml:"branch_trim"`
|
||||
Ellipsis string `yaml:"ellipsis"`
|
||||
HideClean bool `yaml:"hide_clean"`
|
||||
TrailingSpace bool `yaml:"trailing_space"`
|
||||
}
|
||||
|
||||
// A Formater formats git status to a tmux style string.
|
||||
|
|
@ -160,7 +161,14 @@ func (f *Formater) format() string {
|
|||
i++
|
||||
}
|
||||
}
|
||||
return strings.Join(comps[:i], " ")
|
||||
|
||||
var output = strings.Join(comps[:i], " ")
|
||||
|
||||
if f.Options.TrailingSpace {
|
||||
output += " "
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
sb := strings.Builder{}
|
||||
|
|
|
|||
|
|
@ -538,6 +538,42 @@ func TestFormat(t *testing.T) {
|
|||
want: "StyleClear" + "StyleBranch" + "SymbolBranch" +
|
||||
"StyleClear" + "StyleBranch" + "branchName",
|
||||
},
|
||||
{
|
||||
name: "trailing space option false",
|
||||
styles: styles{
|
||||
Clear: "StyleClear",
|
||||
Clean: "StyleClean",
|
||||
},
|
||||
symbols: symbols{
|
||||
Clean: "SymbolClean",
|
||||
},
|
||||
layout: []string{"flags"},
|
||||
st: &gitstatus.Status{
|
||||
IsClean: true,
|
||||
},
|
||||
options: options{
|
||||
TrailingSpace: false,
|
||||
},
|
||||
want: "StyleClear" + "StyleCleanSymbolClean",
|
||||
},
|
||||
{
|
||||
name: "trailing space option true",
|
||||
styles: styles{
|
||||
Clear: "StyleClear",
|
||||
Clean: "StyleClean",
|
||||
},
|
||||
symbols: symbols{
|
||||
Clean: "SymbolClean",
|
||||
},
|
||||
layout: []string{"flags"},
|
||||
st: &gitstatus.Status{
|
||||
IsClean: true,
|
||||
},
|
||||
options: options{
|
||||
TrailingSpace: true,
|
||||
},
|
||||
want: "StyleClear" + "StyleCleanSymbolClean ",
|
||||
},
|
||||
{
|
||||
name: "hide clean option true",
|
||||
styles: styles{
|
||||
|
|
|
|||
Loading…
Reference in a new issue