private boolean isSelectionRangeValid(ProgramSelection selection) throws InvalidInputException {
		Set<String> blockNames = new HashSet<>();
		AddressRangeIterator iter = selection.getAddressRanges();
		while (iter.hasNext()) {
			AddressRange range = iter.next();
			Address addr = range.getMinAddress();
			MemoryBlock block = getCurrentProgram().getMemory().getBlock(addr);
			blockNames.add(block.getName());
		}
		if (blockNames.size() > 1) {
			throw new InvalidInputException("Selection range cannot span memory blocks");
		}

		if (selection.getNumAddressRanges() > 1) {
			throw new InvalidInputException("Selection cannot contain multiple address ranges");
		}
		return selection.getNumAddressRanges() == 1;
	}
Returns true if the user has selected one and only one range of
instructions.

If there are multiple ranges, this could be for two reasons: 1) the user
has (via the mouse) selected more than one set of address ranges, or 2)
the user selects a single region but that region spans memory blocks;
this would be interpreted by the program as being 2 distinct selection
ranges. In both of these cases, we throw an exception with a message that
the caller can log if desired.

@param selection the program selection
@return true if the selection range is valid
@throws InvalidInputException
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/instructionsearch/InstructionSearchPlugin.java