Index: libsrc/org/netbeans/editor/Utilities.java =================================================================== RCS file: /cvs/editor/libsrc/org/netbeans/editor/Utilities.java,v retrieving revision 1.58 diff -r1.58 Utilities.java 421a422,454 > > /** Get the identifier around the given position or null if there's no identifier > * around the given position. The identifier is not verified against SyntaxSupport.isIdentifier(). > * @param c JTextComponent to work on > * @param offset position in document - usually the caret.getDot() > * @return the block (starting and ending position) enclosing the identifier > * or null if no identifier was found > */ > public static int[] getIdentifierBlock(JTextComponent c, int offset) > throws BadLocationException { > int[] ret = null; > int idStart = javax.swing.text.Utilities.getWordStart(c, offset); > if (idStart >= 0) { > int idEnd = javax.swing.text.Utilities.getWordEnd(c, idStart); > Document doc = c.getDocument(); > if (idEnd >= 0) { > String id = doc.getText(idStart, idEnd - idStart); > String trim = id.trim(); > if (trim.length() == 0 || (trim.length() == 1 && !Character.isJavaIdentifierPart(trim.charAt(0)))) { > int prevWordStart = javax.swing.text.Utilities.getPreviousWord(c, offset); > if (offset == javax.swing.text.Utilities.getWordEnd(c,prevWordStart )){ > id = doc.getText(prevWordStart, offset - prevWordStart); > ret = new int[] { prevWordStart, offset }; > } > }else{ > ret = new int[] { idStart, idEnd }; > } > } > } > return ret; > } > > 465c498,499 < if (id.trim().length() == 0) { --- > String trim = id.trim(); > if (trim.length() == 0 || (trim.length() == 1 && !Character.isJavaIdentifierPart(trim.charAt(0)))) { 495c529 < if (caret.isSelectionVisible() || !(doc instanceof BaseDocument)) { --- > if (caret.isSelectionVisible()) { 497c531 < } else { --- > } else if (doc instanceof BaseDocument){ 498a533,534 > } else { > ret = getIdentifierBlock(c, offset);