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

Add code to make autoswap work on Windows. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add code to make autoswap work on Windows. #3

wants to merge 1 commit into from

Conversation

torrinj
Copy link

@torrinj torrinj commented Oct 28, 2014

Some changes to attempt to make this work on Windows using +clientserver. Not perfect, but works.

let l:serverlist = substitute(l:serverlist, "\n", ",", "g")
let l:server_id_to_server_dict = {}
for server in split(l:serverlist, ",")
call remote_send(server, ":call AS_FileLoaded('" . expand("%:p") . "')<CR>", "server_id")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for the PR!

Maybe it is possible to simplify all this code using something like

let fname_esc = substitute(a:filename, "'", "''", "g")
let servername = ...
if remote_expr(servername, "bufloaded('" . fname_esc . "')")
    return servername
endif

Have a look at https://github.com/svintus/vim-editexisting/blob/master/plugin/editexisting.vim#L22-L71.

This technique is not applicable for vim inside a terminal and for some gvim instances, but it is possible that it works fine for win32.

@torrinj
Copy link
Author

torrinj commented Oct 28, 2014

I did a quick test and found that remote_expr() returns a result right away, so using it will probably simplify the code a lot since a bunch of that code was dedicated to just waiting for a response. Now that I think about it, I'm not sure what happens if a VIM is unable to respond right away. I'll have to test it. Anyway, I'll see what I can do with the code a little later.

As for the last line of your comment. I would assume the technique will work where ever VIM is compiled with +clientserver. Are you aware of places where we have +clientserver but the technique doesn't work?

@gioele
Copy link
Owner

gioele commented Oct 29, 2014

It does not simplify the situation when there are GVim instances and Vim instances in terminals, in particular because the latter cannot raise themselves. But I suppose that in Windows all the sessions are Win32 sessions in their own windows, so using the features exposed by +clientserver makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants