Git Product home page Git Product logo

Comments (6)

dvbuntu avatar dvbuntu commented on July 19, 2024

I took a look at this using echo getpos("."). I thought that it would be pretty straightforward to save off the cursor position to a variable, do whatever changes the position, and then setpos(".",foo), but it's tough to find where the position is initially correct (i.e. it seems reset very early in the process).

from slimux.

dvbuntu avatar dvbuntu commented on July 19, 2024

Ok, so I can fix this, but it's dirty and I don't like it.

command! -range -bar -nargs=0 SlimuxREPLSendLine let cur_pos=getpos(".")|<line1>,<line2>call s:SlimeSendRange()|call setpos(".",cur_pos)

At least, this works after setting the the target pane the first time. I suspect that's also resetting the cursor position.

But this seems like a gross way to fix the problem. I'm not an expert with vimscript, so I don't know why the cursor position is already reset to the beginning of the line once you go into the SlimeSendRange function.

One alternative would be to pass the cursor position into these functions. That really seems like mixing functionality, though, so I'm not a big fan of that. I haven't poked at wrapping functions, but maybe that could work?

from slimux.

sunaku avatar sunaku commented on July 19, 2024

Try setting a mark (z) and jumping back to it:

nnoremap j mz:SlimuxREPLSendLine<CR>`z

from slimux.

yzhuang avatar yzhuang commented on July 19, 2024

Yup, saving cursor position into z and restoring afterwards seems to be a simple workaround.

I am using the below settings now, and it works as expected after setting the target pane:

    nmap <Leader>n mz:SlimuxREPLSendLine<CR>`z
    vmap <Leader>n :SlimuxREPLSendSelection<CR>
    nmap <Leader>N :SlimuxREPLConfigure<CR>

    # I configured iterm2 to send 🀄 when Cmd+N is pressed
    imap 🀄  <Esc>mz:SlimuxREPLSendLine<CR>`za
    nmap 🀄  mz:SlimuxREPLSendLine<CR>`z
    vmap 🀄  :SlimuxREPLSendSelection<CR>

Thanks!

from slimux.

dvbuntu avatar dvbuntu commented on July 19, 2024

Setting a mark will work, but it also clobbers that mark. So if you ever use the mark z, you'll lose it after doing a SlimuxREPLSendLine. Probably not a big deal for your specific usage, but it'd be nice to not twiddle that.

from slimux.

yzhuang avatar yzhuang commented on July 19, 2024

Setting a mark will work, but it also clobbers that mark.

Yup, Agree.

I usually use marks a,s,d,f, and rarely need more marks. I guess z is one of the least likely mark I would use. In practice, I think this works fine; as a general solution, this is probably not very clean.

from slimux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.