Skip to content

Commit

Permalink
Show commit index in commit details
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Oct 12, 2024
1 parent aa143ce commit 7b1f89e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ interface VisLine {
}

interface Commit {
i: number
index_in_graph_output: number
vis_lines: VisLine[]
branch?: Branch
hash: string
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils/log-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function parse(log_data, branch_data, stash_data, separator, curve_radius) {
}
}
commits.push({
i: Number(row_no_s),
index_in_graph_output: Number(row_no_s),
vis_lines: Object.values(densened_vis_line_by_branch_id)
// Leftmost branches should appear later so they are on top of the rest
.sort((a, b) => (b.xcs || 0) + (b.xce || 0) - (a.xcs || 0) - (a.xce || 0)),
Expand Down
3 changes: 2 additions & 1 deletion web/src/views/CommitDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
Details
</h3>
<p>
Full hash: {{ commit.hash_long }}
Full hash: {{ commit.hash_long }}<br>
<slot name="details_text" />
</p>
</div>
<div :class="details_panel_position === 'bottom' ? 'flex-1' : ''" class="right">
Expand Down
18 changes: 15 additions & 3 deletions web/src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@
<div v-if="config_show_quick_branch_tips" id="branches-connection">
<commit-row v-if="connection_fake_commit" :commit="connection_fake_commit" :height="110" class="vis" />
</div>
<recycle-scroller id="log" ref="commits_scroller_ref" v-slot="{ item: commit }" v-context-menu="commit_context_menu_provider" :buffer="0" :emit-update="true" :item-size="scroll_item_height" :items="filtered_commits" class="scroller fill-w flex-1" key-field="i" role="list" tabindex="-1" @keydown="scroller_on_keydown" @update="commits_scroller_updated" @wheel="scroller_on_wheel">
<recycle-scroller id="log" ref="commits_scroller_ref" v-slot="{ item: commit }" v-context-menu="commit_context_menu_provider" :buffer="0" :emit-update="true" :item-size="scroll_item_height" :items="filtered_commits" class="scroller fill-w flex-1" key-field="index_in_graph_output" role="list" tabindex="-1" @keydown="scroller_on_keydown" @update="commits_scroller_updated" @wheel="scroller_on_wheel">
<commit-row :class="{selected_commit:selected_commits.includes(commit)}" :commit="commit" :data-commit-hash="commit.hash" role="button" @click="commit_clicked(commit,$event)" />
</recycle-scroller>
</div>
<div v-if="selected_commit || selected_commits.length" id="details-panel" class="col flex-1">
<template v-if="selected_commit">
<commit-details id="selected-commit" :commit="selected_commit" class="flex-1 fill-w padding" @hash_clicked="scroll_to_commit_hash_user($event)" />
<commit-details id="selected-commit" :commit="selected_commit" class="flex-1 fill-w padding" @hash_clicked="scroll_to_commit_hash_user($event)">
<template #details_text>
<template v-if="filtered_commits.length !== commits.length">
Index in filtered commits: {{ selected_commit_index_in_filtered_commits }}<br>
</template>
Index in all loaded commits: {{ selected_commit_index_in_commits }}<br>
Index in raw graph output: {{ selected_commit.index_in_graph_output }}
</template>
</commit-details>
<button id="close-selected-commit" class="center" title="Close" @click="selected_commits=[]">
<i class="codicon codicon-close" />
</button>
Expand Down Expand Up @@ -120,6 +128,10 @@ let selected_commit = computed(() => {
if (selected_commits.value.length === 1)
return selected_commits.value[0]
})
let selected_commit_index_in_filtered_commits = computed(() =>
filtered_commits.value.indexOf(selected_commit.value))
let selected_commit_index_in_commits = computed(() =>
store.commits.value.indexOf(selected_commit.value))
function commit_clicked(/** @type {Commit} */ commit, /** @type {MouseEvent | undefined} */ event) {
if (! commit.hash)
return
Expand Down Expand Up @@ -430,7 +442,7 @@ let commit_context_menu_provider = computed(() => (/** @type {MouseEvent} */ eve
let config_show_quick_branch_tips = computed(() =>
! store.config.value['hide-quick-branch-tips'])
let { combine_branches_from_branch_name, combine_branches_actions, refresh_main_view, selected_git_action, git_status } = store
let { combine_branches_from_branch_name, combine_branches_actions, refresh_main_view, selected_git_action, git_status, commits } = store
</script>
<style scoped>
Expand Down

0 comments on commit 7b1f89e

Please sign in to comment.