Skip to content
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

Issue #22: Initial solution for toggling sorting profiles by percentage #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aidanmatchette
Copy link

Picked two arbitrary keybinds "[" toggles on sortedByPercentage and will toggle back and forth between Asc and Desc order. "]" turns off sorting by percentage. Need to add "instructions" to the key map. i.e. "[ toggle sort by percentage"

Please give feedback on possible better solutions or best practices.

NOT YET COMPLETED:
Screen Shot 2023-02-25 at 7 59 58 PM

I need to still implement adding the key bindings to the "register" of key maps. I could use some tips on this.

Thanks!

Picked two arbitrary keybinds "[" toggles on sortedByPercentage and will
toggle back and forth between Asc and Desc order. "]" turns off sorting
by percentage. Need to add "instructions" to the key map. i.e. "[ toggle
sort by percentage"
Copy link
Owner

@orlangure orlangure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing, thank you! I left one comment for a discussion about the general direction we can take this thing from here in the future.

Of course, after we decide about it, we will need to add a test to this thing, I can help you with that if you get stuck.

@@ -78,6 +78,8 @@ type Model struct {
detectedPackageName string
requestedFiles map[string]bool
filteredLinesByFile map[string][]int
profilesLoaded []*cover.Profile
sortByAsc bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using two boolean flags, I would suggest using an "enum" type with values like SortByPercentage, SortByStatements, SortByName (default one), and a boolean flag that represents asc and desc values. Then, there will be a single key, not two keys as you suggested, that toggle over these 3 values:

  • starting with order by name by default (if the flag is not set)
  • toggle to sort by percentage
  • optionally, if you with to implement as well, toggle to sort by uncovered statements
  • toggle to sort by name again

So the point is that the user only uses a single key to toggle through all possible sorting states.
And then, there is another key that toggles between ascending and descending order. My thoughts were to use s key for sorting mode toggle, and - or ! or z to reverse the order.

Of course if we drop the future requirement to implement 3 different sort modes (at least) your solution with a boolean flag is perfect, so if you don't feel like changing it, that's completely OK 😼

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your idea, and it will get me some practice using enums. Ill mess around with this and start working on some tests. Ill do frequent PRs so you can help guide me. Thanks for the feedback.

@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2023

Codecov Report

Base: 86.12% // Head: 84.79% // Decreases project coverage by -1.33% ⚠️

Coverage data is based on head (cfc9cbb) compared to base (095e557).
Patch coverage: 5.88% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
- Coverage   86.12%   84.79%   -1.33%     
==========================================
  Files          10       10              
  Lines         807      822      +15     
==========================================
+ Hits          695      697       +2     
- Misses         94      107      +13     
  Partials       18       18              
Impacted Files Coverage Δ
internal/model/model.go 87.82% <5.88%> (-3.87%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants