diff options
author | Pierre-Yves B. | 2020-07-30 07:05:12 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-08-03 20:34:38 +0000 |
commit | 1bebc2ee92d1b9b2e5325f51fb6dc28b03803e47 (patch) | |
tree | c872a9694fc0b433a837db3498ce29ce3e5f334d | |
parent | 961c1d1d50f0bd73b5dc3f2e5b37042c63b2ce32 (diff) | |
download | eclipse.platform.text-1bebc2ee92d1b9b2e5325f51fb6dc28b03803e47.tar.gz eclipse.platform.text-1bebc2ee92d1b9b2e5325f51fb6dc28b03803e47.tar.xz eclipse.platform.text-1bebc2ee92d1b9b2e5325f51fb6dc28b03803e47.zip |
Bug 564929 - Delete line shortcut does not delete last editor line
Change-Id: Iae0321abdfc297a41e8abeaee481e6cfbbc5e1c4
Signed-off-by: Pierre-Yves B. <PyvesDev@gmail.com>
-rw-r--r-- | org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextViewerDeleteLineTarget.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextViewerDeleteLineTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextViewerDeleteLineTarget.java index 4ddbd058fd9..c3f6bc0b0c7 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextViewerDeleteLineTarget.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextViewerDeleteLineTarget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Tom Eicher (Avaloq Evolution AG) - block selection mode + * Pierre-Yves Bigourdan, pyvesdev@gmail.com - Bug 564929: Delete line shortcut does not delete last editor line *******************************************************************************/ package org.eclipse.ui.texteditor; @@ -269,6 +270,15 @@ public class TextViewerDeleteLineTarget implements IDeleteLineTarget { resultOffset= document.getLineOffset(line); int endLine= selection.getEndLine(); resultLength= document.getLineOffset(endLine) + document.getLineLength(endLine) - resultOffset; + if (resultLength == 0 && line > 0) { + // Selection is on the last empty line of the editor. Delete + // delimiter of the previous line to effectively remove it. + String previousLineDelimiter= document.getLineDelimiter(line - 1); + if (previousLineDelimiter != null) { + resultOffset-= previousLineDelimiter.length(); + resultLength= previousLineDelimiter.length(); + } + } break; case DeleteLineAction.TO_BEGINNING: |