Skip to content

Commit a201a36

Browse files
committed
fix: make line-height a constant
1 parent 81c79a9 commit a201a36

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

app/components/Code/Viewer.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ const codeRef = useTemplateRef('codeRef')
1313
1414
// Using this so we can track the height of each line, and therefore compute digit sidebar
1515
const lineMultipliers = ref<number[]>([])
16+
const LINE_HEIGHT_PX = 24 // also used in css
1617
1718
function updateLineMultipliers() {
1819
if (!codeRef.value) return
1920
const lines = Array.from(codeRef.value.querySelectorAll('code > .line'))
20-
lineMultipliers.value = lines
21-
.map(line => Math.round(parseFloat(getComputedStyle(line).height) / 24)) // since each line "row" is 24px high
22-
.filter(m => m > 0)
21+
lineMultipliers.value = lines.map(line =>
22+
Math.max(1, Math.round(parseFloat(getComputedStyle(line).height) / LINE_HEIGHT_PX)),
23+
)
2324
}
2425
2526
watch(
@@ -179,8 +180,8 @@ watch(
179180
display: flex;
180181
flex-wrap: wrap;
181182
/* Ensure consistent height matching line numbers */
182-
line-height: 24px;
183-
min-height: 24px;
183+
line-height: calc(v-bind(LINE_HEIGHT_PX) * 1px);
184+
min-height: calc(v-bind(LINE_HEIGHT_PX) * 1px);
184185
white-space: pre-wrap;
185186
overflow: hidden;
186187
transition: background-color 0.1s;

0 commit comments

Comments
 (0)