Skip to content

Commit b629284

Browse files
committed
chore(fileState): uses letters instead of symbols
1 parent 5bc18cc commit b629284

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

lua/tinygit/statusline/file-state.lua

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,11 @@ local function getFileState()
1212
local gitStatus = vim.system({ "git", "-C", gitroot, "status", "--porcelain" }):wait()
1313
if gitStatus.code ~= 0 then return "" end
1414

15-
local icons = {
16-
added = "+",
17-
modified = "~",
18-
deleted = "-",
19-
untracked = "?",
20-
renamed = "R",
21-
}
22-
23-
local changes = vim.iter(vim.split(gitStatus.stdout, "\n")):fold({}, function(acc, line)
15+
local statusLines = vim.split(gitStatus.stdout, "\n", { trimempty = true })
16+
local changes = vim.iter(statusLines):fold({}, function(acc, line)
2417
local label = vim.trim(line:sub(1, 2))
25-
if #label > 1 then label = label:sub(1, 1) end -- prefer staged over unstaged
26-
local map = {
27-
["?"] = icons.untracked,
28-
A = icons.added,
29-
M = icons.modified,
30-
R = icons.renamed,
31-
D = icons.deleted,
32-
}
33-
local key = map[label]
34-
if key then acc[key] = (acc[key] or 0) + 1 end
18+
if #label == 2 then label = label:sub(1, 1) end -- prefer staged over unstaged
19+
acc[label] = (acc[label] or 0) + 1
3520
return acc
3621
end)
3722

0 commit comments

Comments
 (0)