# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\ws\main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: java.editor/src/org/netbeans/modules/editor/java/SelectCodeElementAction.java --- java.editor/src/org/netbeans/modules/editor/java/SelectCodeElementAction.java +++ java.editor/src/org/netbeans/modules/editor/java/SelectCodeElementAction.java @@ -224,6 +224,8 @@ positions.add(new SelectionInfo(caretPos, caretPos)); if (target.getDocument() instanceof BaseDocument) { try { + //as a nice side effect it also supports word selection within string literals + //"foo b|ar" -> bar int block[] = org.netbeans.editor.Utilities.getIdentifierBlock((BaseDocument) target.getDocument(), caretPos); if (block != null) { positions.add(new SelectionInfo(block[0], block[1])); @@ -238,6 +240,17 @@ int endPos = (int)sp.getEndPosition(tp.getCompilationUnit(), tree); positions.add(new SelectionInfo(startPos, endPos)); + //support content selection within the string literal too + //"A|BC" -> ABC + if (tree.getKind() == Tree.Kind.STRING_LITERAL) { + positions.add(new SelectionInfo(startPos + 1, endPos - 1)); + } + //support content selection within the {}-block too + //{A|BC} -> ABC + if (tree.getKind() == Tree.Kind.BLOCK) { + positions.add(new SelectionInfo(startPos + 1, endPos - 1)); + } + //Support selection of JavaDoc int docBegin = Integer.MAX_VALUE; for (Comment comment : treeUtilities.getComments(tree, true)) { @@ -281,9 +294,13 @@ endOffset = NbDocument.findLineOffset(doc, NbDocument.findLineNumber(doc, selectionInfo.getEndOffset()) + 1); } catch (IndexOutOfBoundsException ioobe) {} SelectionInfo next = it.hasNext() ? it.next() : null; + final boolean isEmptySelection = selectionInfo.startOffset == selectionInfo.endOffset; + //don't create line selection for empty selections + if (!isEmptySelection) { if (next == null || startOffset >= next.startOffset && endOffset <= next.endOffset) { orderedPositions.add(new SelectionInfo(startOffset, endOffset)); } + } selectionInfo = next; } }