afrog icon indicating copy to clipboard operation
afrog copied to clipboard

Move-Line-Down doesn't move entire line below last line

Open stenverbois opened this issue 11 years ago • 5 comments

Selecting an entire line (or lines) prevents editor:move-line-down to swap it with the last line in the editor.

Note: It does work when not selecting the entire line (i.e. not selecting the newline char)

GIF:

Repro Steps

  1. Open a file in the main editor
  2. Select an entire line or lines
  3. Use editor:move-line-down (or default Ctrl-Down)
  4. Try to move it below the last line in the editor

Expected: The selected line swaps with the last line Actual: It doesn't do anything

Versions

  • Atom: 1.0.0
  • Electron: 0.22.3
  • OS: linux 3.19.0-15-generic
  • Misc
    • apm 1.0.1
    • npm 2.5.1
    • node 0.10.35
    • python 2.7.9
    • git 2.1.4

This report was created using the package bug-report v0.7.1.

stenverbois avatar Jul 02 '15 12:07 stenverbois

Was able to reproduce it on Windows 7 Atom 1.0.0.

Exactly as written above - occurs only when whole line is selected.

EDIT: Some more details added. Hope it helps.

Case A (no empty line at the end): case_a

Case B (empty line at the end) case_b

# text-editor.coffee
moveLineDown: ->
  selection = @getSelectedBufferRange()
  lastRow = @buffer.getLastRow()
  return if selection.end.row is lastRow
  # case A ends here ^^^^ ... selection.end.row is 1, lastRow is 1
  return if selection.end.row is lastRow - 1 and @buffer.getLastLine() is ''
  # case B ends here ^^^^ ... selection.end.row is 1, lastRow is 2,  @buffer.getLastLine() is ''

kubetz avatar Jul 02 '15 13:07 kubetz

Nice find, that's indeed the code that is causing this I think. The issue may be that selection.end of a fully selected line is on position 0 of the next line? That's where the cursor appears if you press right after selecting.

stenverbois avatar Jul 02 '15 14:07 stenverbois

@stenverbois Yeah, indeed.

I have no idea if it should fixed in moveLineDown directly or deeper in code that is setting selection.end.row and if it is fixed deeper then I am not sure if it won't break something else.

That is the reason I am just writing about it :blush: . It also looks like there are no specs for moving lines :cold_sweat: .

kubetz avatar Jul 02 '15 14:07 kubetz

This was fixed by #8232

benogle avatar Jan 27 '16 20:01 benogle

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

lock[bot] avatar Apr 16 '18 20:04 lock[bot]