@Override
	public int getMaxReplaceLength(int currentIndex) {

		if (currentIndex >= getNumComponents() - 1) {
			return Integer.MAX_VALUE;
		}
		if (isPackingEnabled() || isAtEnd(currentIndex)) {
			return Integer.MAX_VALUE;
		}

		// Can only replace with what fits unless at last component or empty last line.
		DataTypeComponent comp = getComponent(currentIndex);
		int numComponents = getNumComponents();
		if ((currentIndex >= (numComponents - 1)) && (currentIndex <= numComponents)) {
			return Integer.MAX_VALUE; // Last component or empty entry immediately after it.
		}
		if (comp == null) {
			return 0; // No such component. Not at valid edit index.
		}

		// Otherwise, get size of component and number of Undefined bytes after it.
		FieldRange currentRange = getSelectedRangeContaining(currentIndex);
		boolean isOneComponent =
			(currentRange == null) || (currentRange.getStart().getIndex().intValue() +
				1 == currentRange.getEnd().getIndex().intValue());

		if (isOneComponent) {
			return comp.getLength() + getNumUndefinedBytesAfter(comp);
		}
		return getNumBytesInRange(currentRange);
	}
Gets the maximum number of bytes available for a new data type that
will replace the current data type at the indicated index.
If there isn't a component with the indicated index, the max length
will be determined by the lock mode.

@param currentIndex index of the component in the structure.
@return the maximum number of bytes that can be replaced.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java