(snippetId: number, withShift = false)
| 661 | } |
| 662 | |
| 663 | function selectSnippet(snippetId: number, withShift = false) { |
| 664 | if (!withShift) { |
| 665 | selectedSnippetIds.value = [snippetId] |
| 666 | state.snippetId = snippetId |
| 667 | state.snippetContentIndex = 0 |
| 668 | return |
| 669 | } |
| 670 | |
| 671 | if (state.snippetId !== undefined) { |
| 672 | const source = isSearch.value ? snippetsBySearch.value : snippets.value |
| 673 | |
| 674 | if (source?.length) { |
| 675 | const orderedIds = source.map(snippet => snippet.id) |
| 676 | const rangeSelection = getContiguousSelection( |
| 677 | orderedIds, |
| 678 | state.snippetId, |
| 679 | snippetId, |
| 680 | ) |
| 681 | |
| 682 | if (rangeSelection.length) { |
| 683 | selectedSnippetIds.value = rangeSelection |
| 684 | lastSelectedSnippetId.value = snippetId |
| 685 | state.snippetContentIndex = 0 |
| 686 | } |
| 687 | } |
| 688 | } |
| 689 | else { |
| 690 | selectedSnippetIds.value = [snippetId] |
| 691 | lastSelectedSnippetId.value = snippetId |
| 692 | state.snippetId = snippetId |
| 693 | state.snippetContentIndex = 0 |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | function selectFirstSnippet() { |
| 698 | let firstSnippet: SnippetsResponse[0] | undefined |
no test coverage detected