Skip to content

Commit

Permalink
Fix object selection for deprecated instructions (#5816)
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H authored Oct 20, 2023
1 parent a3cd00d commit 6e24dfa
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions newIDE/app/src/EventsSheet/InstructionEditor/InstructionEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,22 @@ export const useInstructionEditor = ({
if (!isNewInstruction) {
// Check if the instruction is an object/behavior instruction. If yes
// select the object, which is the first parameter of the instruction.
const allInstructions = enumerateAllInstructions(isCondition);
const instructionType: string = instruction.getType();
const enumeratedInstructionMetadata = findInstruction(
allInstructions,
instructionType
);
if (
enumeratedInstructionMetadata &&
(enumeratedInstructionMetadata.scope.objectMetadata ||
enumeratedInstructionMetadata.scope.behaviorMetadata)
) {
const objectParameterIndex = getObjectParameterIndex(
enumeratedInstructionMetadata.metadata
);
if (objectParameterIndex !== -1) {
return getChosenObjectState(
instruction.getParameter(objectParameterIndex).getPlainString(),
false /* Even if the instruction is invalid for the object, show it as it's what we have already */
const instructionMetadata = isCondition
? gd.MetadataProvider.getConditionMetadata(
project.getCurrentPlatform(),
instructionType
)
: gd.MetadataProvider.getActionMetadata(
project.getCurrentPlatform(),
instructionType
);
}
const objectParameterIndex = getObjectParameterIndex(instructionMetadata);
if (objectParameterIndex !== -1) {
return getChosenObjectState(
instruction.getParameter(objectParameterIndex).getPlainString(),
false /* Even if the instruction is invalid for the object, show it as it's what we have already */
);
}
}

Expand Down

0 comments on commit 6e24dfa

Please sign in to comment.