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