final CharSequence charSeq = editor.getDocument().getCharsSequence();
// smart backspace is activated only if all characters in the check range are whitespace characters
- for(int pos=startCheckRange; pos<endCheckRange; pos++) {
- final char c = charSeq.charAt(pos);
+ for(int pos=0; pos<caretPos.column; pos++) {
+ // use logicalPositionToOffset to make sure tabs are handled correctly
+ final LogicalPosition checkPos = new LogicalPosition(caretPos.line, pos);
+ final int offset = editor.logicalPositionToOffset(checkPos);
+ final char c = charSeq.charAt(offset);
if (c != '\t' && c != ' ' && c != '\n') {
return null;
}
}
return new LogicalPosition(caretPos.line, column);
}
-
}