mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
vim-patch 8.1.0084: user name completion does not work on MS-Windows
Problem: User name completion does not work on MS-Windows.
Solution: Use NetUserEnum() to get user names. (Yasuhiro Matsumoto)
828c3d7083
This commit is contained in:
@@ -419,6 +419,7 @@ if(Iconv_LIBRARIES)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
list(APPEND NVIM_LINK_LIBRARIES netapi32)
|
||||||
list(APPEND NVIM_LINK_LIBRARIES ${WINPTY_LIBRARIES})
|
list(APPEND NVIM_LINK_LIBRARIES ${WINPTY_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -13,6 +13,9 @@
|
|||||||
#ifdef HAVE_PWD_H
|
#ifdef HAVE_PWD_H
|
||||||
# include <pwd.h>
|
# include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <lm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Initialize users garray and fill it with os usernames.
|
// Initialize users garray and fill it with os usernames.
|
||||||
// Return Ok for success, FAIL for failure.
|
// Return Ok for success, FAIL for failure.
|
||||||
@@ -34,6 +37,26 @@ int os_get_usernames(garray_T *users)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
endpwent();
|
endpwent();
|
||||||
|
# elif defined(WIN32)
|
||||||
|
{
|
||||||
|
DWORD nusers = 0, ntotal = 0, i;
|
||||||
|
PUSER_INFO_0 uinfo;
|
||||||
|
|
||||||
|
if (NetUserEnum(NULL, 0, 0, (LPBYTE *)&uinfo, MAX_PREFERRED_LENGTH,
|
||||||
|
&nusers, &ntotal, NULL) == NERR_Success) {
|
||||||
|
for (i = 0; i < nusers; i++) {
|
||||||
|
char *user;
|
||||||
|
int conversion_result = utf16_to_utf8(uinfo[i].usri0_name, -1, &user);
|
||||||
|
if (conversion_result != 0) {
|
||||||
|
EMSG2("utf16_to_utf8 failed: %d", conversion_result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GA_APPEND(char *, users, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
NetApiBufferFree(uinfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
Reference in New Issue
Block a user