Skip to content

Commit

Permalink
todo notes
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 25, 2020
1 parent d10024c commit c6f0e0b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func checkForGitOrMercurial(curdir string) bool {
// A custom version of extracting extensions for a file
// which deals with extensions specific to code such as
// .travis.yml and the like
// TODO seems to turn DeviceDescription.stories.tsx into strries.tsx not tsx
// TODO this should just get the last extension because we use it for extension filters and not identification
func GetExtension(name string) string {
name = strings.ToLower(name)
ext := filepath.Ext(name)
Expand Down
8 changes: 6 additions & 2 deletions processor/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ func tuiSearch(app *tview.Application, textView *tview.TextView, searchTerm sear
tuiFileWalker.Terminate()
}

// TODO still a race condition here to need to resolve as we call terminate multiple times
// We lock here because we don't want another instance to run until
// this one has terminated which should happen with the terminate call
// NB at this point we have a race condition... many searches are wanting to run in here
// but of course only one gets the lock, which might not be the most recent one...
isRunningMutex.Lock()
defer isRunningMutex.Unlock()

// the search that has run before is newer than this one so abort
// At this point we want to
queuedSearchMutex.Lock()
if queuedSearchLastTime > searchTerm.TimeStamp {
queuedSearchMutex.Unlock()
Expand All @@ -73,9 +74,11 @@ func tuiSearch(app *tview.Application, textView *tview.TextView, searchTerm sear
queuedSearchLastTime = s.TimeStamp
}
}

queuedSearch = []searchTermStruct{}
queuedSearchMutex.Unlock()

// if the search is not mine then return
// if the search is not mine then return because there is something better to do
if queuedSearchLastTime != searchTerm.TimeStamp && search != searchTerm.SearchTerm {
return
}
Expand Down Expand Up @@ -169,6 +172,7 @@ func tuiSearch(app *tview.Application, textView *tview.TextView, searchTerm sear
func drawResults(app *tview.Application, results []*fileJob, textView *tview.TextView, searchTerm string, fileCount int64, inProgress string) {
rankResults(int(fileCount), results)

// TODO this should not be hardcoded
pResults := results
if len(results) > 20 {
pResults = results[:20]
Expand Down

0 comments on commit c6f0e0b

Please sign in to comment.