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:
parent
9516df9fb0
commit
a83a5ccd71
1 changed files with 12 additions and 10 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Todd Papaioannou - initial API and implementation
|
* Todd Papaioannou - initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.actions;
|
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.
|
* that, when invoked, will join the current and next line together.
|
||||||
*
|
*
|
||||||
* @author Todd Papaioannou (toddp@acm.org)
|
* @author Todd Papaioannou (toddp@acm.org)
|
||||||
* @version $Date$
|
* @version $Date: 2005/11/10 15:20:17 $
|
||||||
* @see org.eclipse.ui.texteditor.TextEditorAction
|
* @see org.eclipse.ui.texteditor.TextEditorAction
|
||||||
*/
|
*/
|
||||||
public class JoinLinesAction extends TextEditorAction {
|
public class JoinLinesAction extends TextEditorAction {
|
||||||
|
@ -91,15 +92,16 @@ public class JoinLinesAction extends TextEditorAction {
|
||||||
// What delimeter do we have?
|
// What delimeter do we have?
|
||||||
String delim = theDocument.getLineDelimiter(currentLine);
|
String delim = theDocument.getLineDelimiter(currentLine);
|
||||||
|
|
||||||
// How long is it?
|
if (delim != null) {
|
||||||
int delimLength = delim.length();
|
// How long is it?
|
||||||
|
int delimLength = delim.length();
|
||||||
// Now back track to the last real char in the line
|
|
||||||
int newLineEnd = lineOffset + lineLength - delimLength;
|
// 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);
|
// Replace the delimter char(s) with nothing
|
||||||
|
theDocument.replace(newLineEnd, delimLength, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue