Bug 332597 - deleting a line while selecting the last chars of a file deletes the complete content of the file
Summary: deleting a line while selecting the last chars of a file deletes the complete...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: 3.13.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-25 18:07 UTC by Till Schäfer
Modified: 2014-09-23 18:52 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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