Skip to content

Commit 278852d

Browse files
committed
Select-all works now
1 parent 50b5925 commit 278852d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/extension.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,21 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
673673
if(e.target.tagName !== 'TD' && e.target.tagName !== 'TH') return;
674674
if(editingCell){ if(e.target !== editingCell) editingCell.blur(); else return; } else clearSelection();
675675
const target = e.target;
676+
/* ──────── NEW: select-all via top-left header cell ──────── */
677+
if (
678+
target.tagName === 'TH' && // header cell
679+
!target.hasAttribute('data-col') && // serial-index header has *no* data-col
680+
!target.hasAttribute('data-row') // and no data-row
681+
) {
682+
e.preventDefault(); // stop normal selection
683+
clearSelection();
684+
selectAllCells(); // highlight every th & td
685+
isSelecting = false; // cancel drag-select logic
686+
anchorCell = null;
687+
return; // done
688+
}
689+
/* ──────── END NEW BLOCK ──────── */
690+
676691
selectionMode = (target.tagName === 'TH') ? "column" : (target.getAttribute('data-col') === '-1' ? "row" : "cell");
677692
startCell = target; endCell = target; isSelecting = true; e.preventDefault();
678693
target.focus();
@@ -930,8 +945,12 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
930945
};
931946
table.addEventListener('dblclick', e => { const target = e.target; if(target.tagName !== 'TD' && target.tagName !== 'TH') return; clearSelection(); editCell(target, e); });
932947
const copySelectionToClipboard = () => {
933-
if(currentSelection.length === 0) return;
934-
const coords = currentSelection.map(cell => getCellCoords(cell));
948+
if (currentSelection.length === 0) return;
949+
950+
const coords = currentSelection
951+
.map(cell => getCellCoords(cell))
952+
.filter(c => !isNaN(c.row) && !isNaN(c.col)); // ← keep only valid cells
953+
if (coords.length === 0) return; // nothing to copy
935954
const minRow = Math.min(...coords.map(c => c.row)), maxRow = Math.max(...coords.map(c => c.row));
936955
const minCol = Math.min(...coords.map(c => c.col)), maxCol = Math.max(...coords.map(c => c.col));
937956
let csv = '';

0 commit comments

Comments
 (0)