diff options
-rw-r--r-- | runtime/lua/vim/lsp/sync.lua | 13 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 20 | ||||
-rw-r--r-- | test/functional/plugin/lsp/incremental_sync_spec.lua | 33 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 4 | ||||
-rw-r--r-- | third-party/cmake/BuildLibuv.cmake | 4 | ||||
-rw-r--r-- | third-party/patches/libuv-disable-typedef-MinGW.patch | 19 |
6 files changed, 75 insertions, 18 deletions
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua index 0f4e5b572b..e500be46c2 100644 --- a/runtime/lua/vim/lsp/sync.lua +++ b/runtime/lua/vim/lsp/sync.lua @@ -131,13 +131,22 @@ end ---@param offset_encoding string utf-8|utf-16|utf-32|nil (fallback to utf-8) ---@returns table<int, int> line_idx, byte_idx, and char_idx of first change position local function compute_start_range(prev_lines, curr_lines, firstline, lastline, new_lastline, offset_encoding) + local char_idx + local byte_idx -- If firstline == lastline, no existing text is changed. All edit operations -- occur on a new line pointed to by lastline. This occurs during insertion of -- new lines(O), the new newline is inserted at the line indicated by -- new_lastline. + if firstline == lastline then + local line = prev_lines[firstline - 1] + byte_idx = #line + 1 + char_idx = compute_line_length(line, offset_encoding) + 1 + return { line_idx = firstline - 1, byte_idx = byte_idx, char_idx = char_idx } + end + -- If firstline == new_lastline, the first change occurred on a line that was deleted. -- In this case, the first byte change is also at the first byte of firstline - if firstline == new_lastline or firstline == lastline then + if firstline == new_lastline then return { line_idx = firstline, byte_idx = 1, char_idx = 1 } end @@ -158,8 +167,6 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline, end -- Convert byte to codepoint if applicable - local char_idx - local byte_idx if start_byte_idx == 1 or (#prev_line == 0 and start_byte_idx == 1)then byte_idx = start_byte_idx char_idx = 1 diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 67a2cc96fd..591c658e6b 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -36,7 +36,7 @@ usage() { echo " can be a Vim version (8.0.xxx) or a Git hash." echo " -P {vim-revision} Download, generate and apply a Vim patch." echo " -g {vim-revision} Download a Vim patch." - echo " -s Create a vim-patch pull request." + echo " -s [pr args] Create a vim-patch pull request." echo " -r {pr-number} Review a vim-patch pull request." echo " -V Clone the Vim source code to \$VIM_SOURCE_DIR." echo @@ -329,7 +329,8 @@ stage_patch() { * Do this only for _related_ patches (otherwise it increases the size of the pull request, making it harder to review) - When you are done, try "%s -s" to create the pull request. + When you are done, try "%s -s" to create the pull request, + or "%s -s --draft" to create a draft pull request. See the wiki for more information: * https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim @@ -338,13 +339,19 @@ stage_patch() { } gh_pr() { - gh pr create --title "$1" --body "$2" + local pr_title + local pr_body + pr_title="$1" + pr_body="$2" + shift 2 + gh pr create --title "${pr_title}" --body "${pr_body}" "$@" } git_hub_pr() { local pr_message pr_message="$(printf '%s\n\n%s\n' "$1" "$2")" - git hub pull new -m "${pr_message}" + shift 2 + git hub pull new -m "${pr_message}" "$@" } submit_pr() { @@ -408,7 +415,7 @@ submit_pr() { fi echo "Creating pull request." - if output="$($submit_fn "$pr_title" "$pr_body" 2>&1)"; then + if output="$($submit_fn "$pr_title" "$pr_body" "$@" 2>&1)"; then msg_ok "$output" else msg_err "$output" @@ -799,7 +806,8 @@ while getopts "hlLmMVp:P:g:r:s" opt; do exit 0 ;; s) - submit_pr + shift # remove opt + submit_pr "$@" exit 0 ;; V) diff --git a/test/functional/plugin/lsp/incremental_sync_spec.lua b/test/functional/plugin/lsp/incremental_sync_spec.lua index 4e3eddb960..da54f3c649 100644 --- a/test/functional/plugin/lsp/incremental_sync_spec.lua +++ b/test/functional/plugin/lsp/incremental_sync_spec.lua @@ -207,16 +207,16 @@ describe('incremental synchronization', function() { range = { ['start'] = { - character = 0, - line = 1 + character = 11, + line = 0, }, ['end'] = { character = 0, line = 1 } }, - rangeLength = 0, - text = 'hello world\n' + rangeLength = 1, + text = '\nhello world\n' } } test_edit({"hello world"}, {"yyp"}, expected_text_changes, 'utf-16', '\n') @@ -226,19 +226,38 @@ describe('incremental synchronization', function() { range = { ['start'] = { + character = 11, + line = 0 + }, + ['end'] = { character = 0, line = 1 + } + }, + rangeLength = 1, + text = '\n\n' + } + } + test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n') + end) + it('adding a line to an empty buffer', function() + local expected_text_changes = { + { + range = { + ['start'] = { + character = 0, + line = 0 }, ['end'] = { character = 0, line = 1 } }, - rangeLength = 0, - text = '\n' + rangeLength = 1, + text = '\n\n' } } - test_edit({"hello world"}, {"o"}, expected_text_changes, 'utf-16', '\n') + test_edit({""}, {"o"}, expected_text_changes, 'utf-16', '\n') end) end) describe('multi line edit', function() diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 2001171378..3c96954c9f 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -144,8 +144,8 @@ endif() include(ExternalProject) -set(LIBUV_URL https://github.com/libuv/libuv/archive/7ae0c9543d0080968766288c73874aee3798ae30.tar.gz) -set(LIBUV_SHA256 02ade646f52221e56f2515f8d0bfb8099204d21f6973b2a139bc726807ea803c) +set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.42.0.tar.gz) +set(LIBUV_SHA256 371e5419708f6aaeb8656671f89400b92a9bba6443369af1bb70bcd6e4b3c764) set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/cpp-3.0.0/msgpack-3.0.0.tar.gz) set(MSGPACK_SHA256 bfbb71b7c02f806393bc3cbc491b40523b89e64f83860c58e3e54af47de176e4) diff --git a/third-party/cmake/BuildLibuv.cmake b/third-party/cmake/BuildLibuv.cmake index 42650308a8..1d6a217575 100644 --- a/third-party/cmake/BuildLibuv.cmake +++ b/third-party/cmake/BuildLibuv.cmake @@ -63,6 +63,10 @@ elseif(WIN32) set(BUILD_SHARED ON) elseif(MINGW) set(BUILD_SHARED OFF) + set(LIBUV_PATCH_COMMAND + ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libuv init + COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libuv apply --ignore-whitespace + ${CMAKE_CURRENT_SOURCE_DIR}/patches/libuv-disable-typedef-MinGW.patch) else() message(FATAL_ERROR "Trying to build libuv in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}") endif() diff --git a/third-party/patches/libuv-disable-typedef-MinGW.patch b/third-party/patches/libuv-disable-typedef-MinGW.patch new file mode 100644 index 0000000000..a47893cede --- /dev/null +++ b/third-party/patches/libuv-disable-typedef-MinGW.patch @@ -0,0 +1,19 @@ +diff --git a/include/uv/win.h b/include/uv/win.h +index f5f1d3a3..64a0dfd9 100644 +--- a/include/uv/win.h ++++ b/include/uv/win.h +@@ -45,7 +45,14 @@ typedef struct pollfd { + #endif + + #include <mswsock.h> ++// Disable the typedef in mstcpip.h of MinGW. ++#define _TCP_INITIAL_RTO_PARAMETERS _TCP_INITIAL_RTO_PARAMETERS__ ++#define TCP_INITIAL_RTO_PARAMETERS TCP_INITIAL_RTO_PARAMETERS__ ++#define PTCP_INITIAL_RTO_PARAMETERS PTCP_INITIAL_RTO_PARAMETERS__ + #include <ws2tcpip.h> ++#undef _TCP_INITIAL_RTO_PARAMETERS ++#undef TCP_INITIAL_RTO_PARAMETERS ++#undef PTCP_INITIAL_RTO_PARAMETERS + #include <windows.h> + + #include <process.h> |