Skip to content

Commit

Permalink
Remove commitStatusChar option and fix double space issue
Browse files Browse the repository at this point in the history
- Remove commitStatusChar config option and hardcode '*' instead
- Change logic in `commits.go` so it only colors non empty strings
  • Loading branch information
oliviaBahr committed Apr 26, 2024
1 parent 0bbf3d9 commit 6ea35f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ gui:
showIcons: false # deprecated: use nerdFontsVersion instead
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
showFileIcons: true # for hiding file icons in the file views
commitHashLength: 8 # length of commit hash in commits view
commitStatusChar: "" # What to show instead of hash if commitHashLength==0 and NF icons aren't on. Empty string to show nothing.
commitHashLength: 8 # length of commit hash in commits view. 0 shows '*' if NF icons aren't enabled
commandLogSize: 8
splitDiff: 'auto' # one of 'auto' | 'always'
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
Expand Down
7 changes: 1 addition & 6 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ type GuiConfig struct {
NerdFontsVersion string `yaml:"nerdFontsVersion" jsonschema:"enum=2,enum=3,enum="`
// If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.
ShowFileIcons bool `yaml:"showFileIcons"`
// Length of commit hash in commits view.
// If 0 and NF icons aren't enabled, show 'commitStatusChar' instead of hash.
// Length of commit hash in commits view. 0 shows '*' if NF icons aren't on.
CommitHashLength int `yaml:"commitHashLength" jsonschema:"minimum=0"`
// What to show instead of hash if commitHashLength==0 and NF icons aren't on
// Empty string to show nothing
CommitStatusChar string `yaml:"commitStatusChar"`
// If true, show commit hashes alongside branch names in the branches view.
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
// Height of the command log view
Expand Down Expand Up @@ -682,7 +678,6 @@ func GetDefaultConfig() *UserConfig {
NerdFontsVersion: "",
ShowFileIcons: true,
CommitHashLength: 8,
CommitStatusChar: "●",
ShowBranchCommitHash: false,
CommandLogSize: 8,
SplitDiff: "auto",
Expand Down
13 changes: 7 additions & 6 deletions pkg/gui/presentation/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,16 @@ func displayCommit(
) []string {
bisectString := getBisectStatusText(bisectStatus, bisectInfo)

hashString := commit.Hash
hashString := ""
hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
hashLength := common.UserConfig.Gui.CommitHashLength
if hashLength == 0 && !icons.IsIconEnabled() { // if no icons and no hash, show a char so user still sees status color
hashString = common.UserConfig.Gui.CommitStatusChar
} else if hashLength < len(hashString) {
hashString = hashString[:hashLength]
if hashLength >= len(commit.Hash) {
hashString = hashColor.Sprint(commit.Hash)
} else if hashLength > 0 {
hashString = hashColor.Sprint(commit.Hash[:hashLength])
} else if !icons.IsIconEnabled() { // hashLength == 0
hashString = hashColor.Sprint("*")
}
hashString = hashColor.Sprint(hashString)

divergenceString := ""
if commit.Divergence != models.DivergenceNone {
Expand Down
7 changes: 1 addition & 6 deletions schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,9 @@
"commitHashLength": {
"type": "integer",
"minimum": 0,
"description": "Length of commit hash in commits view.\nIf 0 and NF icons aren't enabled, show 'commitStatusChar' instead of hash.",
"description": "Length of commit hash in commits view. 0 shows '*' if NF icons aren't on.",
"default": 8
},
"commitStatusChar": {
"type": "string",
"description": "What to show instead of hash if commitHashLength==0 and NF icons aren't on\nEmpty string to show nothing",
"default": ""
},
"showBranchCommitHash": {
"type": "boolean",
"description": "If true, show commit hashes alongside branch names in the branches view."
Expand Down

0 comments on commit 6ea35f4

Please sign in to comment.