Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: Moving left and right was skipping newlines #7253

Merged
merged 1 commit into from
Jun 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function edit_move_left(buf::IOBuffer)
#move to the next base UTF8 character to the left
while true
c = char_move_left(buf)
if charwidth(c) != 0 || position(buf) == 0
if charwidth(c) != 0 || c == '\n' || position(buf) == 0
break
end
end
Expand Down Expand Up @@ -374,7 +374,7 @@ function edit_move_right(buf::IOBuffer)
pos = position(buf)
nextc = read(buf,Char)
seek(buf,pos)
(charwidth(nextc) != 0) && break
(charwidth(nextc) != 0 || nextc == '\n') && break
end
return true
end
Expand Down
21 changes: 21 additions & 0 deletions test/lineedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,27 @@ run_test(test3_func,IOBuffer("aab"))
@test a_bar == 2
@test b_bar == 1

## edit_move{left,right} ##
buf = IOBuffer("a\na\na\n")
seek(buf, 0)
for i = 1:6
LineEdit.edit_move_right(buf)
@test position(buf) == i
end
@test eof(buf)
for i = 5:0
LineEdit.edit_move_left(buf)
@test position(buf) == i
end

# skip unicode combining characters
buf = IOBuffer("ŷ")
seek(buf, 0)
LineEdit.edit_move_right(buf)
@test eof(buf)
LineEdit.edit_move_left(buf)
@test position(buf) == 0

## edit_move_{up,down} ##

buf = IOBuffer("type X\n a::Int\nend")
Expand Down