Skip to content

Commit

Permalink
replace slice with map for 'toParse' files...
Browse files Browse the repository at this point in the history
prevents some circumstances where a file gets added twice
(and so its todos are doubly included in the UI)
  • Loading branch information
NiloCK committed Feb 2, 2024
1 parent 7a33d32 commit 4387d31
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,39 @@ import (
)

func Run() {
wdStr, err := os.Getwd() // [ ] only from cli flag? YES! or... follow .gitignore
wrkdirStr, err := os.Getwd() // [ ] only from cli flag? YES! or... follow .gitignore

if err != nil {
panic(err)
}

adoptConfigSettings(filepath.Join(wdStr, ".tuido"))
adoptConfigSettings(filepath.Join(wrkdirStr, ".tuido"))
// [ ] read cli flags for added extensions / extension specificity

files := []string{}
files := make(map[string]struct{})

wtStat, err := os.Stat(runConfig.writeto)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if wtStat.IsDir() {
files = append(files, getFiles(runConfig.writeto, runConfig.extensions)...)
writeDirFiles := getFiles(runConfig.writeto, runConfig.extensions)
for _, f := range writeDirFiles {
files[f] = struct{}{}
}
}

// [ ] replace with subdir check #active=2022-05-26 #zzz=2
if wdStr != runConfig.writeto {
wdFiles := getFiles(wdStr, runConfig.extensions)
files = append(files, wdFiles...)
if wrkdirStr != runConfig.writeto {
wdFiles := getFiles(wrkdirStr, runConfig.extensions)
for _, f := range wdFiles {
files[f] = struct{}{}
}
}

items := []*tuido.Item{}
for _, f := range files {
for f := range files {
items = append(items, getItems(f)...)
}

Expand Down

0 comments on commit 4387d31

Please sign in to comment.