1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for Bug 166639 - JoinLinesAction throws NPE at last line

This commit is contained in:
Anton Leherbauer 2006-12-05 09:21:59 +00:00
parent 9516df9fb0
commit a83a5ccd71

View file

@ -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);
}
}
}