#1337 "Move selected lines" commands mess up last line without \n

Bug
closed-fixed
Neil Hodgson
Scintilla (789)
4
2012-04-20
2012-03-25
Eugene
No

"Move selected lines" commands do not properly handle last line without trailing newline. For example, if you try to move that line up, it will collapse with the previous line. I attach a patch that fixes it. Feel free to post any suggestions on improving the patch if it can't be committed as is. The patch is made for Scintilla 2.29

Discussion

  • Eugene
    Eugene
    2012-03-25

    The patch

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2012-03-26

    This is a minor issue that should be fixable with a simple patch, not 100 lines. It looks like all the patch is doing is inserting an extra line end. Changes to an existing file should copy the style of the file, including bracket layout.

     
  • Neil Hodgson
    Neil Hodgson
    2012-03-26

    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 4
    • status: open --> open-accepted
     
  • Eugene
    Eugene
    2012-03-26

    > This is a minor issue that should be fixable with a simple patch, not 100
    lines. It looks like all the patch is doing is inserting an extra line end.

    Fairly enough. I attach a new, shorter patch.

    > Changes to an existing file should copy the style of the file, including
    bracket layout.

    Whoops, sorry. This is fixed in the new patch, too.

     
  • Eugene
    Eugene
    2012-03-26

    The patch, version 2

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2012-03-30

    The generated line end may not be in the selected text if the file is using mixed line ends. The actual length of the line end at the end of the selection can be determined more directly using LineEnd and LineStart.

    Instead of rearranging selectedText it should be simpler to just InsertString the line end and the text without line end.

     
  • Eugene
    Eugene
    2012-03-31

    The patch, version 3

     
    Attachments
  • Eugene
    Eugene
    2012-03-31

    Thanks for the suggestions. Another version of the patch attached.

     
  • Marko Njezic
    Marko Njezic
    2012-03-31

    The provided patch doesn't work properly when moving up to the first line. Also, while moving line end of previous line may be fine in a file with all the same line endings, someone might object to it in case of a file with mixed line endings.

    Here's the proper patch, which approaches the problem differently by adding missing line ends as needed (when moving up and down): http://pastebin.com/EAHEzzkw

     
  • Neil Hodgson
    Neil Hodgson
    2012-04-04

    Committed patch from Marko.

     
  • Neil Hodgson
    Neil Hodgson
    2012-04-04

    • status: open-accepted --> open-fixed
     
  • Eugene
    Eugene
    2012-04-04

    OK, thanks, Marko and Neil.

     
  • Neil Hodgson
    Neil Hodgson
    2012-04-20

    • status: open-fixed --> closed-fixed