# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\Development\_workspace\mercurial_repo\netbeans\Netbeans_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: editor.lib/src/org/netbeans/editor/BaseKit.java --- editor.lib/src/org/netbeans/editor/BaseKit.java Base (BASE) +++ editor.lib/src/org/netbeans/editor/BaseKit.java Locally Modified (Based On LOCAL) @@ -1939,9 +1939,11 @@ // If on last line (without newline) then insert newline at very end temporarily // then cut and remove previous newline. int removeNewlineOffset = -1; - if (!Utilities.isSelectionShowing(target)) { + int caretPosition = target.getCaretPosition(); + boolean emptySelection = !Utilities.isSelectionShowing(target); + if (emptySelection) { Element elem = ((AbstractDocument) target.getDocument()).getParagraphElement( - target.getCaretPosition()); + caretPosition); int lineStartOffset = elem.getStartOffset(); int lineEndOffset = elem.getEndOffset(); if (lineEndOffset == doc.getLength() + 1) { // Very end @@ -1967,6 +1969,9 @@ // Could not remove ending newline } } + if (emptySelection) { + target.setCaretPosition(caretPosition); + } } finally { DocumentUtilities.setTypingModification(doc, false); } @@ -1986,18 +1991,24 @@ //#54893 putValue ("helpID", CopyAction.class.getName ()); // NOI18N } + @Override public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { try { + int caretPosition = target.getCaretPosition(); + boolean emptySelection = !Utilities.isSelectionShowing(target); // If there is no selection then pre-select a current line including newline - if (!Utilities.isSelectionShowing(target)) { + if (emptySelection) { Element elem = ((AbstractDocument) target.getDocument()).getParagraphElement( - target.getCaretPosition()); + caretPosition); if (!Utilities.isRowWhite((BaseDocument) target.getDocument(), elem.getStartOffset())) { target.select(elem.getStartOffset(), elem.getEndOffset()); } } target.copy(); + if (emptySelection) { + target.setCaretPosition(caretPosition); + } } catch (BadLocationException ble) { LOG.log(Level.FINE, null, ble); }