From b28d20fc1a4e0f59d713ca3f138bd8c839f3fbe0 Mon Sep 17 00:00:00 2001 From: XiNGRZ Date: Sat, 6 Apr 2024 21:42:45 +0800 Subject: [PATCH] Unbind row indexes from BSRow This significantly increased performance of inserting new lines, as Vue doesn't need to dispatch changes of row index of the rows below newly inserted row. Instead, the focus state of each row is revalidate only when needed. --- src/components/BSMap.vue | 10 +++++++++- src/components/BSMap/BSCell.vue | 5 ++--- src/components/BSMap/BSRow.vue | 23 ++++++++++++++++++----- src/components/BSMap/BSSelectable.vue | 22 +++------------------- src/components/BSMap/BSText.vue | 5 ++--- 5 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/components/BSMap.vue b/src/components/BSMap.vue index da83c6b..f3cd127 100644 --- a/src/components/BSMap.vue +++ b/src/components/BSMap.vue @@ -1,6 +1,6 @@ @@ -41,6 +41,14 @@ const style = computed(() => ({ '--bs-map-cols': cols.value, }) as CSSProperties); +function isFocused(row: number): boolean { + const { selection } = editorStore; + return ( + typeof selection != 'undefined' && + selection.row == row + ); +} + function handleSelect(row: number, offset: number, length: number): void { editorStore.selection = { row: row, diff --git a/src/components/BSMap/BSCell.vue b/src/components/BSMap/BSCell.vue index 0da93ce..f38b110 100644 --- a/src/components/BSMap/BSCell.vue +++ b/src/components/BSMap/BSCell.vue @@ -1,5 +1,5 @@