public void removeSpaceToLastLineBreak(IContext ctx) {
        boolean shouldRemoveSpace = true;
        List<Token> bl = builders();
        for (int i = bl.size() - 1; i >= 0; --i) {
            TextBuilder tb = bl.get(i);
            if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) {
                continue;
            }
            if (tb.getClass().equals(Token.StringToken.class)) {
                String s = tb.toString();
                if (s.matches("[ \\t\\x0B\\f]+")) {
                    continue;
                } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) {
                } else {
                    shouldRemoveSpace = false;
                }
            }
            break;
        }
        if (shouldRemoveSpace) {
            for (int i = bl.size() - 1; i >= 0; --i) {
                TextBuilder tb = bl.get(i);
                if (tb == Token.EMPTY_TOKEN || tb instanceof IDirective) {
                    continue;
                }
                if (tb.getClass().equals(Token.StringToken.class)) {
                    String s = tb.toString();
                    if (s.matches("[ \\t\\x0B\\f]+")) {
                        bl.remove(i);
                        continue;
                    } else if (s.matches("(\\n\\r|\\r\\n|[\\r\\n])")) {
                        bl.remove(i);
                    }
                }
                break;
            }
        }
    }
public void removeSpaceToLastLineBreak ( IContext ctx ) { boolean shouldRemoveSpace = true ; List < Token > bl = builders ( ) ; for ( int i = bl . size ( ) - 1 ; i >= 0 ; -- i ) { TextBuilder tb = bl . get ( i ) ; if ( tb == Token . EMPTY_TOKEN || tb instanceof IDirective ) { continue ; } if ( tb . getClass ( ) . equals ( Token . StringToken . class ) ) { String s = tb . toString ( ) ; if ( s . matches ( "[ \\t\\x0B\\f]+" ) ) { continue ; } else if ( s . matches ( "(\\n\\r|\\r\\n|[\\r\\n])" ) ) { } else { shouldRemoveSpace = false ; } } break ; } if ( shouldRemoveSpace ) { for ( int i = bl . size ( ) - 1 ; i >= 0 ; -- i ) { TextBuilder tb = bl . get ( i ) ; if ( tb == Token . EMPTY_TOKEN || tb instanceof IDirective ) { continue ; } if ( tb . getClass ( ) . equals ( Token . StringToken . class ) ) { String s = tb . toString ( ) ; if ( s . matches ( "[ \\t\\x0B\\f]+" ) ) { bl . remove ( i ) ; continue ; } else if ( s . matches ( "(\\n\\r|\\r\\n|[\\r\\n])" ) ) { bl . remove ( i ) ; } } break ; } } }
If from the current cursor to last linebreak are all space, then
remove all those spaces and the last line break