Bug 332597

Summary: deleting a line while selecting the last chars of a file deletes the complete content of the file
Product: [Applications] kate Reporter: Till Schäfer <till2.schaefer>
Component: partAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: michal.humpula
Priority: NOR    
Version: 3.13.0   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Till Schäfer 2014-03-25 18:07:07 UTC
A new feature was introduced in bug 286262. When you select multiple lines and press the delete line(s) shortcut, all selected lines are deleted.

This new feature introduces a new bug:

Reproducible: Always

Steps to Reproduce:
1. open a multi line text file in kate
2. select the last chars of the file 
3. press the delete line shortcut

Actual Results:  
the complete document is empty

Expected Results:  
ony the lines that are selected are deletet

the feature works well if i select multiple or single lines at the front or in the middle of the document. 

is selected 3.12.60 in the tracker because 3.12.95 version was not available
Comment 1 Dominik Haumann 2014-04-07 08:54:13 UTC
@Michal: May it be, that we should cache the end line? i.e.:

 void KateView::killLine( )
 {
  if (m_selection.isEmpty()) {
    m_doc->removeLine(cursorPosition().line());
  } else {
    m_doc->editStart();
-    for (int line = m_selection.end().line(); line >= m_selection.start().line(); line--) {
+    const int startLine = m_selection.start().line();
+    for (int line = m_selection.range.end().line(); line >= startLine; line--) {
      m_doc->removeLine(line);
    }
    m_doc->editEnd();
  }
}
Comment 2 Christoph Cullmann 2014-09-23 18:52:28 UTC
Git commit af907b0faf9dcccf0e981d4a17eedaed7d414e77 by Christoph Cullmann.
Committed on 23/09/2014 at 18:51.
Pushed by cullmann into branch 'master'.

fix kill line with selection if last line is selected
good catch Dominik, the endLine is altered and we delete everything!

M  +2    -1    src/view/kateview.cpp

http://commits.kde.org/ktexteditor/af907b0faf9dcccf0e981d4a17eedaed7d414e77