From a83a5ccd71beb0ea72f96cdb2df33dede2b9c7c8 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 5 Dec 2006 09:21:59 +0000 Subject: [PATCH] Fix for Bug 166639 - JoinLinesAction throws NPE at last line --- .../internal/ui/actions/JoinLinesAction.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/JoinLinesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/JoinLinesAction.java index 54754c8c8d2..8ea51f81604 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/JoinLinesAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/JoinLinesAction.java @@ -7,6 +7,7 @@ * * Contributors: * Todd Papaioannou - initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -27,7 +28,7 @@ import org.eclipse.ui.texteditor.TextEditorAction; * that, when invoked, will join the current and next line together. * * @author Todd Papaioannou (toddp@acm.org) - * @version $Date$ + * @version $Date: 2005/11/10 15:20:17 $ * @see org.eclipse.ui.texteditor.TextEditorAction */ public class JoinLinesAction extends TextEditorAction { @@ -91,15 +92,16 @@ public class JoinLinesAction extends TextEditorAction { // What delimeter do we have? String delim = theDocument.getLineDelimiter(currentLine); - // How long is it? - int delimLength = delim.length(); - - // Now back track to the last real char in the line - int newLineEnd = lineOffset + lineLength - delimLength; - - // Replace the delimter char(s) with nothing - theDocument.replace(newLineEnd, delimLength, null); - + if (delim != null) { + // How long is it? + int delimLength = delim.length(); + + // Now back track to the last real char in the line + int newLineEnd = lineOffset + lineLength - delimLength; + + // Replace the delimter char(s) with nothing + theDocument.replace(newLineEnd, delimLength, null); + } } }