Users should be able to select points (not just lines) (#97)

* update selection datastructure to accomodate more selection metadata

* Users should be able to select points (not just lines)
This commit is contained in:
Kurt Hutten
2023-04-03 16:05:25 +10:00
committed by GitHub
parent 7013eb861d
commit a8b68bab6a
25 changed files with 292 additions and 146 deletions

View File

@ -1,5 +1,5 @@
import { PathToNode, ProgramMemory } from './executor'
import { Range } from '../useStore'
import { Selection } from '../useStore'
import {
BinaryExpression,
Program,
@ -96,7 +96,7 @@ export function getNodeFromPathCurry(
function moreNodePathFromSourceRange(
node: Value | ExpressionStatement | VariableDeclaration | ReturnStatement,
sourceRange: Range,
sourceRange: Selection['range'],
previousPath: PathToNode = [['body', '']]
): PathToNode {
const [start, end] = sourceRange
@ -239,7 +239,7 @@ function moreNodePathFromSourceRange(
export function getNodePathFromSourceRange(
node: Program,
sourceRange: Range,
sourceRange: Selection['range'],
previousPath: PathToNode = [['body', '']]
): PathToNode {
const [start, end] = sourceRange
@ -269,7 +269,7 @@ export interface PrevVariable<T> {
export function findAllPreviousVariables(
ast: Program,
programMemory: ProgramMemory,
sourceRange: Range,
sourceRange: Selection['range'],
type: 'number' | 'string' = 'number'
): {
variables: PrevVariable<typeof type extends 'number' ? number : string>[]