Skip to content

Commit

Permalink
scroll to selected commit scroll pos by clicking the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed May 1, 2023
1 parent a1629ea commit 84a8949
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions web/src/views/CommitDetails.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import RefTip from './RefTip.vue'

export default defineComponent
components: { GitActionButton, RefTip }
emits: ['hash_clicked']
props:
commit:
###* @type {() => Commit} ###
Expand Down
6 changes: 5 additions & 1 deletion web/src/views/CommitDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ div
.row.gap-5.wrap
git-action-button v-for="action of tag_actions(tag.name)" :git_action="action"

h3 This commit {{ commit.hash }}:
h3
| This commit
button @click="$emit('hash_clicked',commit.hash)"
| {{ commit.hash }}
| :
.row.gap-5.wrap
git-action-button v-for="action of commit_actions" :git_action="action"

Expand Down
8 changes: 7 additions & 1 deletion web/src/views/MainView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ export default
# Not only scroll to tip, but also select it, so the behavior is equal to clicking on
# a branch name in a commit's ref list.
store.selected_commit.value = filtered_commits.value[first_branch_commit_i]

scroll_to_commit = (###* @type string ### hash) =>
commit_i = filtered_commits.value.findIndex (commit) =>
commit.hash == hash
if commit_i == -1
return show_error_message "No commit found for hash #{hash}. No idea why :/"
commits_scroller_ref.value?.scrollToItem commit_i



Expand Down Expand Up @@ -251,6 +256,7 @@ export default
visible_branches
commits_scroller_ref
scroll_to_branch_tip
scroll_to_commit
selected_commit: store.selected_commit
txt_filter
txt_filter_ref
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
progress.diff v-if="commit.stats" :value="(commit.stats.insertions / (commit.stats.insertions + commit.stats.deletions)) || 0" title="Ratio insertions / deletions"
.datetime.flex-noshrink {{ commit.datetime }}
#right.col.flex-1 v-if="selected_commit"
commit-details#selected-commit.flex-1.fill-w.padding :commit="selected_commit"
commit-details#selected-commit.flex-1.fill-w.padding :commit="selected_commit" @hash_clicked="scroll_to_commit($event)"
button#close-selected-commit.center @click="selected_commit=null" title="Close"
i.codicon.codicon-close
#resize-hint v-if="selected_commit"
Expand Down

0 comments on commit 84a8949

Please sign in to comment.