int dif = offset - fReplacementOffset;
if (fReplacementString.equals("elif")) {
doc.replace(offset, 0, fReplacementString.substring(dif));
//check if we should dedent
PyAutoIndentStrategy strategy = new PyAutoIndentStrategy();
DocCmd cmd = new DocCmd(offset + fReplacementString.length() - dif, 0, " ");
Tuple<String, Integer> dedented = PyAutoIndentStrategy.autoDedentElif(doc, cmd,
strategy.getIndentPrefs());
doc.replace(cmd.offset, 0, " :");
//make up for the ' :' (right before ':')
if (dedented != null) {
changeInCursorPos = -dedented.o2 + 1;
}
return;
} else if (fReplacementString.endsWith(":")) { //else:, finally:, except: ...
//make the replacement for the 'else'
String replacementString = fReplacementString.substring(0, fReplacementString.length() - 1);
doc.replace(offset, 0, replacementString.substring(dif));
//dedent if needed
PyAutoIndentStrategy strategy = new PyAutoIndentStrategy();
DocCmd cmd = new DocCmd(offset + replacementString.length() - dif, 0, ":");
Tuple<String, Integer> dedented = PyAutoIndentStrategy.autoDedentAfterColon(doc, cmd,
strategy.getIndentPrefs());
doc.replace(cmd.offset, 0, ":");
//make up for the ':'
if (dedented != null) {
changeInCursorPos = -dedented.o2;
}