Skip to content

Commit

Permalink
Fix #3152
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Feb 25, 2025
1 parent d5094f0 commit 70c5181
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions frontend/components/CellInput/scopestate_statefield.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ const i_am_nth_child = (cursor) => {
* @returns {Range[]}
*/
const explore_funcdef_arguments = (cursor, { enter, leave }) => {
VERBOSE && console.assert(cursor.name === "TupleExpression" || cursor.name === "Arguments", cursor.name)

let found = []

const position_validation = cursor_not_moved_checker(cursor)
Expand All @@ -148,26 +150,36 @@ const explore_funcdef_arguments = (cursor, { enter, leave }) => {
if (!cursor.firstChild()) throw new Error(`Expected to go into function definition argument expression, stuck at ${cursor.name}`)
// should be in the TupleExpression now

// @ts-ignore
VERBOSE && console.assert(cursor.name === "TupleExpression" || cursor, name === "Arguments", cursor.name)

cursor.firstChild()
do {
if (cursor.name === "KeywordArguments") {
cursor.firstChild() // go into kwarg arguments
}

const explore_argument = () => {
if (cursor.name === "Identifier" || cursor.name === "Operator") {
found.push(r(cursor))
} else if (cursor.name === "KwArg") {
let went_in = cursor.firstChild()
found.push(r(cursor))
// cursor.nextSibling()
explore_argument()
cursor.nextSibling()
// find stuff used here
// cursor.iterate(enter, leave)
cursor.iterate(enter, leave)

if (went_in) cursor.parent()
} else if (cursor.name === "BinaryExpression") {
let went_in = cursor.firstChild()
explore_argument()
cursor.nextSibling()
cursor.nextSibling()
// find stuff used here
cursor.iterate(enter, leave)

if (went_in) cursor.parent()
}
}

do {
if (cursor.name === "KeywordArguments") {
cursor.firstChild() // go into kwarg arguments
}
explore_argument()
} while (cursor.nextSibling())

position_resetter()
Expand Down

0 comments on commit 70c5181

Please # to comment.