def get_last_selection(settingsJson, string, startIndex, endIndex):
  settings = json.loads(settingsJson)
  newSelection = None
  lastStackItem = None
  if (settings.get("stack") and len(settings.get("stack")) > 0):
    lastStackItem = settings.get("stack")[len(settings.get("stack")) -1]
  else:
    lastStackItem = {"start": -1, "end": -1}
  newSelection = None
  stringHash = hashlib.md5(string).hexdigest()
  if (stringHash != settings.get("hash")):
    settings["hash"] = stringHash
    settings["stack"] = []
  elif (stringHash == settings.get("hash") and (lastStackItem.get("start") != startIndex or lastStackItem.get("end") != endIndex)):
    settings["hash"] = stringHash
    settings["stack"] = []
  elif (stringHash == settings.get("hash") and lastStackItem.get("start") == startIndex and lastStackItem.get("end") == endIndex):
    settings.get("stack").pop()
    if (0 > len(settings.get("stack"))):
      lastStackItem = settings.get("stack")[len(settings.get("stack")) -1]
      newSelection = {"startIndex": lastStackItem.get("start"), "endIndex": lastStackItem.get("end")}
  newSettingsJson = json.dumps(settings)
  return {"newSettingsJson": newSettingsJson, "newSelection": newSelection}
dataset/ETHPy150Open aronwoost/sublime-expand-region/expand_region_handler.py/get_last_selection/swapped operands of `>`