esamattis / slimux

SLIME inspired tmux integration plugin for Vim
http://esa-matti.suuronen.org/blog/2012/04/19/slimux-tmux-plugin-for-vim/
Other
217 stars 52 forks source link

Julia for loop break #51

Closed michaellindon closed 8 years ago

michaellindon commented 8 years ago

When I send a block of code under visual mode to the repl it always breaks half way through a for loop:

screenshot from 2015-11-05 10-17-28

slashfoo commented 8 years ago

@michaellindon thanks for the report.

Can you please provide a sample file so I can test this? I could just re-type what I see on your screenshot but I'm not familiar with .jl ( I assume julia ) and don't know if you have any 'conceal' settings in vim set up.

michaellindon commented 8 years ago

Thank you =)

n=1000
ł=0.01
p=1
ν=p+0.5
λ=sqrt(2*ν)/ł
σ²=1.0
q=2*σ²*√π*λ^(2p+1)*gamma(p+1)/gamma(p+0.5)
d=2
F=Array(Float64,d,d)
F[1,1]=0
F[1,2]=1
F[2,1]=-λ^2
F[2,2]=-2λ
L=zeros(d,1)
L[d,1]=1
# sylvester(A, B, C) Computes the solution X to the Sylvester equation AX + XB + C = 0
M=Dict(0=>sylvester(F,F',L*q*L'))
t=Dict(zip(collect(0:n),[0;sort(rand(n))]))
Δ=Dict(zip(collect(1:n),[t[k]-t[k-1] for k=1:n]))
Q=Dict()
x=Dict(0=>zeros(d,1))
for i=1:n
    A=expm(F*Δ[i])
    H=expm(Δ[i]*vcat(hcat(-F,L*q*L'),hcat(zeros(d,d),F')))
    A=H[d+1:end,d+1:end]'
    x[i]=A*x[i-1]
end
slashfoo commented 8 years ago

Hey, I just tried the file and I could replicate the issue, I think the problem here is that the file is too long. If you select only the for...end section under visual and send that, I could get it to work.

If you break off and put a blank line before the for, and send that as a paragraph, it will work.

I had not tried to send a big chunk of text like that but now I could replicate with other languages, not only Julia.

In the meantime, please use the workaround of sending it in smaller chunks while I work on figuring this one out. And thanks again for the report.

slashfoo commented 8 years ago

As I suspected, it has to do with the length of the block that you're trying to send, apparently there's a bug in the "split and send in chunks" code, another workaround you can try for the time being is changing the 500 on Line 212 of plugin/slimux file, for a larger value. I can't say what very large values may cause, but tried with the same file with the value 1000 and it succeeded on my machine.

sunaku commented 8 years ago

:scream: Splitting and escaping is totally unnecessary (not to mention brittle). See PR #52 for solution. :neckbeard:

slashfoo commented 8 years ago

Thanks @sunaku ! ok, one less ticket!