Skip to content

Commit e49245c

Browse files
committed
feat: highlight select row
1 parent 6bf1326 commit e49245c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/views/history/components/CommitTable/ListItem.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ const props = defineProps<{
1313
prevGraphData?: GitOperation
1414
nextGraphData?: GitOperation
1515
columnWidths: Record<string, number>
16+
isSelected?: boolean
1617
}>()
1718
19+
const emit = defineEmits(['select'])
20+
1821
const hoveredCell = ref<string | null>(null)
1922
2023
function handleCommitClick() {
24+
// Emit the selection event
25+
emit('select')
26+
2127
try {
2228
if (window.vscode) {
2329
window.vscode.postMessage({
@@ -46,7 +52,12 @@ function handleDoubleClick() {
4652
</script>
4753

4854
<template>
49-
<li class="commit-row" @click="handleCommitClick" @dblclick="handleDoubleClick">
55+
<li
56+
class="commit-row"
57+
:class="{ selected: isSelected }"
58+
@click="handleCommitClick"
59+
@dblclick="handleDoubleClick"
60+
>
5061
<!-- <div class="branch-col commit-cell" :style="{ width: `${columnWidths.branch}px` }">
5162
<GitGraph
5263
:graph-data="graphData"
@@ -105,6 +116,15 @@ function handleDoubleClick() {
105116
background-color: var(--vscode-list-hoverBackground);
106117
}
107118
119+
.commit-row.selected {
120+
background-color: var(--vscode-list-activeSelectionBackground);
121+
color: var(--vscode-list-activeSelectionForeground);
122+
}
123+
124+
.commit-row.selected .hash-col {
125+
color: var(--vscode-list-activeSelectionForeground);
126+
}
127+
108128
.commit-cell {
109129
white-space: nowrap;
110130
overflow: hidden;

src/views/history/components/CommitTable/index.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const props = defineProps<{
1212
graphData: GitOperation[]
1313
}>()
1414
15+
// Selected commit hash state
16+
const selectedCommitHash = ref<string | null>(null)
17+
1518
const ITEMS_PER_PAGE = 45
1619
const currentPage = ref(1)
1720
const observer = ref<IntersectionObserver | null>(null)
@@ -49,6 +52,11 @@ const visibleCommits = computed(() => {
4952
return commitData.value.slice(0, end)
5053
})
5154
55+
// Handle commit selection
56+
function handleCommitSelected(hash: string) {
57+
selectedCommitHash.value = hash
58+
}
59+
5260
onMounted(() => {
5361
observer.value = new IntersectionObserver((entries) => {
5462
const target = entries[0]
@@ -80,7 +88,9 @@ onUnmounted(() => {
8088
:prev-graph-data="index > 0 ? graphData[index - 1] : null"
8189
:next-graph-data="index < graphData.length - 1 ? graphData[index + 1] : null"
8290
:commit="commit"
83-
:column-widths="columnWidths"
91+
:column-widths="columnWidths"
92+
:is-selected="selectedCommitHash === commit.hash"
93+
@select="handleCommitSelected(commit.hash)"
8494
/>
8595
<li ref="loadingTriggerRef" class="loading-trigger">
8696
<div v-if="visibleCommits.length < commitData.length" class="loading-text">

0 commit comments

Comments
 (0)