1.1 --- a/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/PlsqlTypedBreakInterceptor.java Thu May 02 17:29:38 2013 +0200
1.2 +++ b/PLSQL/Formatter/src/org/netbeans/modules/plsql/format/PlsqlTypedBreakInterceptor.java Fri May 03 09:26:22 2013 +0200
1.3 @@ -32,12 +32,8 @@
1.4 }
1.5 BaseDocument doc = (BaseDocument) context.getDocument();
1.6 int insertPos = context.getCaretOffset();
1.7 - int lineStartPos = Utilities.getRowStart(doc, insertPos);
1.8 - String word = Utilities.getWord(doc, lineStartPos);
1.9 - if (word.equals("--") && isInitialComment(doc, insertPos)) {
1.10 + if (wordInRowBelowStartsWith(doc, insertPos, "--")) {
1.11 context.setText("\n-- ", 0, 5);
1.12 - } else if (word.equals("--------------------")) {
1.13 - context.setText("\n-------------------- ", 0, 22);
1.14 }
1.15 }
1.16
1.17 @@ -51,15 +47,10 @@
1.18 LOG.log(Level.FINER, "cancelled, context: {0}", context);
1.19 }
1.20
1.21 - private boolean isInitialComment(BaseDocument doc, int insertPos) throws BadLocationException {
1.22 - for (int i = 0; i < Utilities.getLineOffset(doc, insertPos); i++) {
1.23 - int rowStartFromLineOffset = Utilities.getRowStartFromLineOffset(doc, i);
1.24 - String word = Utilities.getWord(doc, rowStartFromLineOffset);
1.25 - if (!word.startsWith("--")) {
1.26 - return false;
1.27 - }
1.28 - }
1.29 - return true;
1.30 + private boolean wordInRowBelowStartsWith(BaseDocument doc, int insertPos, String word) throws BadLocationException {
1.31 + int currentRow = Utilities.getLineOffset(doc, insertPos);
1.32 + int rowStartFromLineOffset = Utilities.getRowStartFromLineOffset(doc, currentRow + 1);
1.33 + return Utilities.getWord(doc, rowStartFromLineOffset).startsWith(word);
1.34 }
1.35
1.36 @MimeRegistration(mimeType = PlsqlDataLoader.REQUIRED_MIME, service = TypedBreakInterceptor.Factory.class)