Merge pull request #19158 from overleaf/mj-commands-autocomplete-optional-args

[web] Avoid double counting optional arguments for autocomplete

GitOrigin-RevId: 7abdc73657791b945bd5a7a9e29f5cd127c7882b
This commit is contained in:
Mathias Jakobsen 2024-06-26 13:39:29 +01:00 committed by Copybot
parent 1844603a2d
commit abaf07a8bb

View file

@ -108,7 +108,8 @@ export const enterNode = (
}
const optionalArguments = commandNode.getChildren('OptionalArgument')
const commandArguments = commandNode.getChildren('$Argument')
const commandArgumentsIncludingOptional =
commandNode.getChildren('$Argument')
const text = state.doc.sliceString(ctrlSeq.from, ctrlSeq.to)
const thisCommand = {
@ -117,7 +118,8 @@ export const enterNode = (
from: commandNode.from,
to: commandNode.to,
optionalArgCount: optionalArguments.length,
requiredArgCount: commandArguments.length,
requiredArgCount:
commandArgumentsIncludingOptional.length - optionalArguments.length,
}
items.push(thisCommand)
}