-
-
Notifications
You must be signed in to change notification settings - Fork 325
Label completions #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+789
−18
Merged
Label completions #720
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
022bc30
Increase issue label fetch limit
mchisolm0 5d9b795
Merge branch 'dlvhdr:main' into main
mchisolm0 1322d83
Create labelapi.go
mchisolm0 0782dab
Create autocomplete.go
mchisolm0 d87b41e
Add autocomplete support for input and issue view
mchisolm0 a8be8e5
Fix join function to add ", " to last label
mchisolm0 ce275ec
Move variable definitions
mchisolm0 4cbc86e
Rename to Selected and SetConfigure
mchisolm0 4fb292b
Remove SetConfigure and Config
mchisolm0 f48fd9b
Add SelectionIcon
mchisolm0 ce6b259
Refactor label styling
mchisolm0 acd1b0d
Refactor Prev method to use early return
mchisolm0 88f7c1f
Fix suggestions not showing up
mchisolm0 07a4ffb
Refactor to use sahilm/fuzzy library
mchisolm0 afdfa77
Refactor to remove label extraction from autocomplete
mchisolm0 bda09ba
Move autocomplete keybindings to autocomplete.go
mchisolm0 8c7955f
Add feature to autocomplete labels anywhere in the list
mchisolm0 5b5172b
Refactor to better organize labels
mchisolm0 697523d
Rename Filter to Show
mchisolm0 d00c3c5
Move autocomplete view to above help
mchisolm0 6b94cee
Add fetch labels keybinding
mchisolm0 0ba6cfc
Fix padding
mchisolm0 3a1924a
Refactor suggestions help
mchisolm0 3ffc975
Refactor replacing labels to use runes
mchisolm0 c8bde2a
Rename FetchLabels names to be more generic
mchisolm0 6b90ced
Remove unused functions
mchisolm0 57e83c5
Rename currentLabel function to labelAtCursor
mchisolm0 feab01b
Rename variable to clarify it is the cached version
mchisolm0 a466d89
Check repo label cache under lock
mchisolm0 100399e
Add fetch suggestions status
mchisolm0 3820cc1
Move keybindings
mchisolm0 c68639c
Improve clarity
mchisolm0 5283e79
Increase limit of labels to request
mchisolm0 be0a6d8
Fix trimming whitespace to match excluded suggestions
mchisolm0 700eadd
Fix subtracting padding multiple times
mchisolm0 4437a0c
Add space between glyph and error message
mchisolm0 d3aeb99
Fix focusing the input box
mchisolm0 d2e71fc
Fix returning the error message if the fetch errors
mchisolm0 d8065c1
Fix SetWidth
mchisolm0 f52d6a3
Rename variables to make Show function generic
mchisolm0 2a90c32
Make UpdateVisible function to check hiddenByUser state
mchisolm0 e3749e4
Shrink inputbox
mchisolm0 113afb4
Clear cache before a user initiated fetch
mchisolm0 388d06d
Improve loading spinner positioning
mchisolm0 ab46238
Auto-clear autocomplete fetch status
mchisolm0 94d5e73
Remove unused positions
mchisolm0 26e481d
Improve spacing of suggestions
mchisolm0 e23c50f
Update styles for fetch text
mchisolm0 16d1c81
Add function to update the program context to autocomplete
mchisolm0 95b5688
Refactor to handle refresh keybind the bubbletea way
mchisolm0 17ff5cb
Add bold style to selected suggestion
mchisolm0 be480c4
fix: Remove extra space
mchisolm0 092b66e
fix: Capitalize Ctrl+n
mchisolm0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package data | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "os/exec" | ||
| "strings" | ||
| "sync" | ||
| ) | ||
|
|
||
| var ( | ||
| repoLabelCache = make(map[string][]Label) | ||
| labelCacheMu sync.RWMutex | ||
| // execCommand is injectable for testing; defaults to exec.Command | ||
| execCommand = exec.Command | ||
| ) | ||
|
|
||
| func GetCachedRepoLabels(repoNameWithOwner string) ([]Label, bool) { | ||
| labelCacheMu.RLock() | ||
| defer labelCacheMu.RUnlock() | ||
| labels, ok := repoLabelCache[repoNameWithOwner] | ||
| return labels, ok | ||
| } | ||
|
|
||
| func FetchRepoLabels(repoNameWithOwner string) ([]Label, error) { | ||
| // Check cache first | ||
| if cachedLabels, ok := GetCachedRepoLabels(repoNameWithOwner); ok { | ||
| return cachedLabels, nil | ||
| } | ||
|
|
||
| cmd := execCommand("gh", "label", "list", "-R", repoNameWithOwner, "--json", "name,color", "--limit", "300") | ||
| output, err := cmd.Output() | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| var labels []Label | ||
| if err := json.Unmarshal(output, &labels); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| filteredLabels := make([]Label, 0, len(labels)) | ||
| for _, label := range labels { | ||
| if strings.TrimSpace(label.Name) != "" { | ||
| filteredLabels = append(filteredLabels, label) | ||
| } | ||
| } | ||
|
|
||
| labelCacheMu.Lock() | ||
| defer labelCacheMu.Unlock() | ||
|
|
||
| if labels, ok := repoLabelCache[repoNameWithOwner]; ok { | ||
| return labels, nil | ||
| } | ||
|
|
||
| repoLabelCache[repoNameWithOwner] = filteredLabels | ||
| return filteredLabels, nil | ||
| } | ||
|
|
||
| func ClearLabelCache() { | ||
| labelCacheMu.Lock() | ||
| defer labelCacheMu.Unlock() | ||
| repoLabelCache = make(map[string][]Label) | ||
| } | ||
|
|
||
| func ClearRepoLabelCache(repoNameWithOwner string) { | ||
| labelCacheMu.Lock() | ||
| defer labelCacheMu.Unlock() | ||
| delete(repoLabelCache, repoNameWithOwner) | ||
| } | ||
|
|
||
| func GetLabelNames(labels []Label) []string { | ||
| names := make([]string, len(labels)) | ||
| for i, label := range labels { | ||
| names[i] = label.Name | ||
| } | ||
| return names | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.