aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nvim/CMakeLists.txt97
-rw-r--r--src/nvim/api/ui.c10
-rw-r--r--src/nvim/msgpack_rpc/channel.c11
-rw-r--r--src/nvim/option_defs.h2
-rw-r--r--src/nvim/optionstr.c3
-rw-r--r--src/nvim/po/CMakeLists.txt12
-rwxr-xr-xsrc/nvim/testdir/runnvim.sh4
-rw-r--r--src/nvim/testdir/suite.sh10
-rw-r--r--src/nvim/testdir/test.sh91
-rw-r--r--src/nvim/ui.c6
-rw-r--r--src/nvim/ui.h2
11 files changed, 169 insertions, 79 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index fd1c3c28db..52bafffefe 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -135,8 +135,7 @@ if(MINGW)
target_compile_definitions(main_lib INTERFACE __USE_MINGW_ANSI_STDIO)
endif()
if(WIN32)
- # Windows Vista is the minimum supported version
- target_compile_definitions(main_lib INTERFACE _WIN32_WINNT=0x0600 MSWIN)
+ target_compile_definitions(main_lib INTERFACE _WIN32_WINNT=0x0602 MSWIN)
endif()
# OpenBSD's GCC (4.2.1) doesn't have -Wvla
@@ -449,12 +448,12 @@ set(gen_cflags ${gen_cflags} -O2)
set(NVIM_VERSION_GIT_H ${PROJECT_BINARY_DIR}/cmake.config/auto/versiondef_git.h)
add_custom_target(update_version_stamp
COMMAND ${CMAKE_COMMAND}
- -DNVIM_VERSION_MAJOR=${NVIM_VERSION_MAJOR}
- -DNVIM_VERSION_MINOR=${NVIM_VERSION_MINOR}
- -DNVIM_VERSION_PATCH=${NVIM_VERSION_PATCH}
- -DNVIM_VERSION_PRERELEASE=${NVIM_VERSION_PRERELEASE}
- -DOUTPUT=${NVIM_VERSION_GIT_H}
- -DNVIM_SOURCE_DIR=${CMAKE_SOURCE_DIR}
+ -D NVIM_VERSION_MAJOR=${NVIM_VERSION_MAJOR}
+ -D NVIM_VERSION_MINOR=${NVIM_VERSION_MINOR}
+ -D NVIM_VERSION_PATCH=${NVIM_VERSION_PATCH}
+ -D NVIM_VERSION_PRERELEASE=${NVIM_VERSION_PRERELEASE}
+ -D OUTPUT=${NVIM_VERSION_GIT_H}
+ -D NVIM_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-P ${PROJECT_SOURCE_DIR}/cmake/GenerateVersion.cmake
BYPRODUCTS ${NVIM_VERSION_GIT_H})
@@ -665,9 +664,14 @@ else()
target_compile_definitions(nvim PRIVATE $<$<CONFIG:Debug>:UNIT_TESTING>)
endif()
-target_sources(nvim PRIVATE ${NVIM_GENERATED_FOR_SOURCES} ${NVIM_GENERATED_FOR_HEADERS}
- ${NVIM_GENERATED_SOURCES} ${NVIM_SOURCES} ${NVIM_HEADERS}
- ${EXTERNAL_SOURCES} ${EXTERNAL_HEADERS})
+target_sources(main_lib INTERFACE
+ ${NVIM_GENERATED_FOR_SOURCES}
+ ${NVIM_GENERATED_FOR_HEADERS}
+ ${NVIM_GENERATED_SOURCES}
+ ${NVIM_SOURCES}
+ ${NVIM_HEADERS}
+ ${EXTERNAL_SOURCES}
+ ${EXTERNAL_HEADERS})
set_target_properties(nvim
PROPERTIES
@@ -706,9 +710,9 @@ if(WIN32)
add_custom_target(nvim_dll_deps DEPENDS nvim
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/windows_runtime_deps
COMMAND ${CMAKE_COMMAND}
- "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
- -DBINARY="${PROJECT_BINARY_DIR}/bin/nvim${CMAKE_EXECUTABLE_SUFFIX}"
- -DDST=${PROJECT_BINARY_DIR}/windows_runtime_deps
+ -D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
+ -D BINARY="${PROJECT_BINARY_DIR}/bin/nvim${CMAKE_EXECUTABLE_SUFFIX}"
+ -D DST=${PROJECT_BINARY_DIR}/windows_runtime_deps
-P ${PROJECT_SOURCE_DIR}/cmake/WindowsDllCopy.cmake)
add_dependencies(nvim_runtime_deps nvim_dll_deps)
@@ -810,14 +814,7 @@ install(DIRECTORY ${BINARY_LIB_DIR}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/nvim/
USE_SOURCE_PERMISSIONS)
-add_library(
- libnvim
- STATIC
- EXCLUDE_FROM_ALL
- ${NVIM_SOURCES} ${NVIM_GENERATED_SOURCES}
- ${NVIM_HEADERS} ${NVIM_GENERATED_FOR_SOURCES} ${NVIM_GENERATED_FOR_HEADERS}
- ${EXTERNAL_SOURCES} ${EXTERNAL_HEADERS}
-)
+add_library(libnvim STATIC EXCLUDE_FROM_ALL)
if(MSVC)
set(LIBNVIM_NAME libnvim)
else()
@@ -860,63 +857,35 @@ elseif(CLANG_TSAN)
target_link_libraries(nvim PRIVATE -fsanitize=thread)
endif()
-function(get_test_target prefix sfile relative_path_var target_var)
- get_filename_component(full_d "${sfile}" DIRECTORY)
- file(RELATIVE_PATH d "${PROJECT_SOURCE_DIR}/src/nvim" "${full_d}")
- if(d MATCHES "^[.][.]")
- file(RELATIVE_PATH d "${GENERATED_DIR}" "${full_d}")
- endif()
- get_filename_component(r "${sfile}" NAME)
- if(NOT d MATCHES "^[.]?$")
- set(r "${d}/${r}")
- endif()
- string(REGEX REPLACE "[/.]" "-" suffix "${r}")
- set(${relative_path_var} ${r} PARENT_SCOPE)
- if(prefix STREQUAL "")
- set(${target_var} "${suffix}" PARENT_SCOPE)
- else()
- set(${target_var} "${prefix}-${suffix}" PARENT_SCOPE)
- endif()
-endfunction()
-
+find_program(CLANG_TIDY_PRG clang-tidy)
+set(EXCLUDE_CLANG_TIDY typval_encode.c.h ui_events.in.h)
if(WIN32)
- set(NO_SINGLE_CHECK_HEADERS
+ list(APPEND EXCLUDE_CLANG_TIDY
os/pty_process_unix.h
os/unix_defs.h)
else()
- set(NO_SINGLE_CHECK_HEADERS
+ list(APPEND EXCLUDE_CLANG_TIDY
os/win_defs.h
os/pty_process_win.h
os/pty_conpty_win.h
os/os_win_console.h)
endif()
-foreach(hfile ${NVIM_HEADERS})
- get_test_target(test-includes "${hfile}" relative_path texe)
-
- if(NOT ${hfile} MATCHES "[.](c|in)[.]h$")
- set(tsource "${GENERATED_DIR}/${relative_path}.test-include.c")
- write_file("${tsource}" "#include \"${hfile}\"\nint main(int argc, char **argv) { return 0; }")
- add_executable(
- ${texe}
- EXCLUDE_FROM_ALL
- ${tsource} ${NVIM_HEADERS} ${NVIM_GENERATED_FOR_HEADERS})
- target_link_libraries(${texe} PRIVATE main_lib)
- set_target_properties(${texe} PROPERTIES FOLDER test)
-
- list(FIND NO_SINGLE_CHECK_HEADERS "${relative_path}" hfile_exclude_idx)
- if(${hfile_exclude_idx} EQUAL -1)
- list(APPEND HEADER_CHECK_TARGETS ${texe})
- endif()
- endif()
-endforeach()
-add_custom_target(check-single-includes DEPENDS ${HEADER_CHECK_TARGETS})
+add_glob_target(
+ TARGET clang-tidy
+ COMMAND ${CLANG_TIDY_PRG}
+ FILES ${NVIM_SOURCES} ${NVIM_HEADERS}
+ FLAGS --quiet
+ EXCLUDE ${EXCLUDE_CLANG_TIDY})
+add_custom_target(copy_compile_commands
+ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/compile_commands.json ${PROJECT_SOURCE_DIR}/compile_commands.json)
+add_dependencies(copy_compile_commands nvim)
+add_dependencies(clang-tidy copy_compile_commands)
if(CI_BUILD)
set(LINT_OUTPUT_FORMAT gh_action)
else()
set(LINT_OUTPUT_FORMAT vs7)
endif()
-
add_glob_target(
TARGET lintc-clint
COMMAND ${PROJECT_SOURCE_DIR}/src/clint.py
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index e67607a7e4..3ad625234c 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -202,6 +202,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona
data->flushed_events = false;
data->ncalls_pos = NULL;
data->ncalls = 0;
+ data->ncells_pending = 0;
data->buf_wptr = data->buf;
data->temp_buf = NULL;
data->wildmenu_active = false;
@@ -854,18 +855,25 @@ void remote_ui_raw_line(UI *ui, Integer grid, Integer row, Integer startcol, Int
mpack_uint(buf, repeat);
}
}
+ data->ncells_pending += MIN(repeat, 2);
last_hl = attrs[i];
repeat = 0;
}
}
if (endcol < clearcol) {
nelem++;
+ data->ncells_pending += 1;
mpack_array(buf, 3);
mpack_str(buf, " ");
mpack_uint(buf, (uint32_t)clearattr);
mpack_uint(buf, (uint32_t)(clearcol - endcol));
}
mpack_w2(&lenpos, nelem);
+
+ if (data->ncells_pending > 500) {
+ // pass of cells to UI to let it start processing them
+ remote_ui_flush_buf(ui);
+ }
} else {
for (int i = 0; i < endcol - startcol; i++) {
remote_ui_cursor_goto(ui, row, startcol + i);
@@ -917,6 +925,8 @@ void remote_ui_flush_buf(UI *ui)
// we have sent events to the client, but possibly not yet the final "flush"
// event.
data->flushed_events = true;
+
+ data->ncells_pending = 0;
}
/// An intentional flush (vsync) when Nvim is finished redrawing the screen
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index d60e18590f..34c8f89e3f 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -247,10 +247,13 @@ static void parse_msgpack(Channel *channel)
Unpacker *p = channel->rpc.unpacker;
while (unpacker_advance(p)) {
if (p->type == kMessageTypeRedrawEvent) {
- if (p->grid_line_event) {
- ui_client_event_raw_line(p->grid_line_event);
- } else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) {
- p->ui_handler.fn(p->result.data.array);
+ // When exiting, ui_client_stop() has already been called, so don't handle UI events.
+ if (ui_client_channel_id && !exiting) {
+ if (p->grid_line_event) {
+ ui_client_event_raw_line(p->grid_line_event);
+ } else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) {
+ p->ui_handler.fn(p->result.data.array);
+ }
}
arena_mem_free(arena_finish(&p->arena));
} else if (p->type == kMessageTypeResponse) {
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index d190fc5999..0e0cc4c983 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -630,6 +630,8 @@ EXTERN unsigned rdb_flags;
#define RDB_NOTHROTTLE 0x002
#define RDB_INVALID 0x004
#define RDB_NODELTA 0x008
+#define RDB_LINE 0x010
+#define RDB_FLUSH 0x020
EXTERN long p_rdt; // 'redrawtime'
EXTERN long p_re; // 'regexpengine'
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 901477d869..7efbeadb2f 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -125,7 +125,8 @@ static char *(p_spo_values[]) = { "camel", "noplainbuffer", NULL };
static char *(p_icm_values[]) = { "nosplit", "split", NULL };
static char *(p_jop_values[]) = { "stack", "view", NULL };
static char *(p_tpf_values[]) = { "BS", "HT", "FF", "ESC", "DEL", "C0", "C1", NULL };
-static char *(p_rdb_values[]) = { "compositor", "nothrottle", "invalid", "nodelta", NULL };
+static char *(p_rdb_values[]) = { "compositor", "nothrottle", "invalid", "nodelta", "line",
+ "flush", NULL };
static char *(p_sloc_values[]) = { "last", "statusline", "tabline", NULL };
/// All possible flags for 'shm'.
diff --git a/src/nvim/po/CMakeLists.txt b/src/nvim/po/CMakeLists.txt
index 1db21880bb..a5a3c135d3 100644
--- a/src/nvim/po/CMakeLists.txt
+++ b/src/nvim/po/CMakeLists.txt
@@ -100,12 +100,12 @@ if(HAVE_WORKING_LIBINTL AND GETTEXT_FOUND AND XGETTEXT_PRG AND ICONV_PRG)
add_custom_target(update-po-${lang}
COMMAND ${CMAKE_COMMAND}
- -DICONV_PRG=${ICONV_PRG}
- -DINPUT_FILE=${inputFile}
- -DOUTPUT_FILE=${outputFile}
- -DINPUT_ENC=${inputEnc}
- -DOUTPUT_ENC=${outputEnc}
- -DOUTPUT_CHARSET=${outputCharSet}
+ -D ICONV_PRG=${ICONV_PRG}
+ -D INPUT_FILE=${inputFile}
+ -D OUTPUT_FILE=${outputFile}
+ -D INPUT_ENC=${inputEnc}
+ -D OUTPUT_ENC=${outputEnc}
+ -D OUTPUT_CHARSET=${outputCharSet}
-P ${PROJECT_SOURCE_DIR}/cmake/ConvertPo.cmake
COMMENT "Updating ${outputName}.po"
DEPENDS ${inputFile})
diff --git a/src/nvim/testdir/runnvim.sh b/src/nvim/testdir/runnvim.sh
index 3a0a94b6bf..4d8ea0527d 100755
--- a/src/nvim/testdir/runnvim.sh
+++ b/src/nvim/testdir/runnvim.sh
@@ -22,13 +22,11 @@ main() {(
i=$(( i+1 ))
done
- export CI_DIR="$root/ci"
BUILD_DIR="$(dirname "$nvim_prg")/.."
export BUILD_DIR
export FAILED=0
- . "$CI_DIR/common/suite.sh"
- . "$CI_DIR/common/test.sh"
+ . $(dirname $0)/test.sh
# Redirect XDG_CONFIG_HOME so users local config doesn't interfere
export XDG_CONFIG_HOME="$root"
diff --git a/src/nvim/testdir/suite.sh b/src/nvim/testdir/suite.sh
new file mode 100644
index 0000000000..bf5a16fd89
--- /dev/null
+++ b/src/nvim/testdir/suite.sh
@@ -0,0 +1,10 @@
+fail() {
+ local test_name="$1"
+ local message="$2"
+
+ : "${message:=Test $test_name failed}"
+
+ local full_msg="$test_name :: $message"
+ echo "Failed: $full_msg"
+ export FAILED=1
+}
diff --git a/src/nvim/testdir/test.sh b/src/nvim/testdir/test.sh
new file mode 100644
index 0000000000..affdc308d1
--- /dev/null
+++ b/src/nvim/testdir/test.sh
@@ -0,0 +1,91 @@
+fail() {
+ local test_name="$1"
+ local message="$2"
+
+ : "${message:=Test $test_name failed}"
+
+ local full_msg="$test_name :: $message"
+ echo "Failed: $full_msg"
+ export FAILED=1
+}
+
+print_core() {
+ local app="$1"
+ local core="$2"
+ if test "$app" = quiet ; then
+ echo "Found core $core"
+ return 0
+ fi
+ echo "======= Core file $core ======="
+ if test "${CI_OS_NAME}" = osx ; then
+ lldb -Q -o "bt all" -f "${app}" -c "${core}"
+ else
+ gdb -n -batch -ex 'thread apply all bt full' "${app}" -c "${core}"
+ fi
+}
+
+check_core_dumps() {
+ local del=
+ if test "$1" = "--delete" ; then
+ del=1
+ shift
+ fi
+ local app="${1:-${BUILD_DIR}/bin/nvim}"
+ local cores
+ if test "${CI_OS_NAME}" = osx ; then
+ cores="$(find /cores/ -type f -print)"
+ local _sudo='sudo'
+ else
+ cores="$(find ./ -type f \( -name 'core.*' -o -name core -o -name nvim.core \) -print)"
+ local _sudo=
+ fi
+
+ if test -z "${cores}" ; then
+ return
+ fi
+ local core
+ for core in $cores; do
+ if test "$del" = "1" ; then
+ print_core "$app" "$core" >&2
+ "$_sudo" rm "$core"
+ else
+ print_core "$app" "$core"
+ fi
+ done
+ if test "$app" != quiet ; then
+ fail 'cores' 'Core dumps found'
+ fi
+}
+
+check_logs() {
+ # Iterate through each log to remove an useless warning.
+ # shellcheck disable=SC2044
+ for log in $(find "${1}" -type f -name "${2}"); do
+ sed -i "${log}" \
+ -e '/Warning: noted but unhandled ioctl/d' \
+ -e '/could cause spurious value errors to appear/d' \
+ -e '/See README_MISSING_SYSCALL_OR_IOCTL for guidance/d'
+ done
+
+ # Now do it again, but only consider files with size > 0.
+ local err=""
+ # shellcheck disable=SC2044
+ for log in $(find "${1}" -type f -name "${2}" -size +0); do
+ cat "${log}"
+ err=1
+ rm "${log}"
+ done
+ if test -n "${err}" ; then
+ fail 'logs' 'Runtime errors detected.'
+ fi
+}
+
+valgrind_check() {
+ check_logs "${1}" "valgrind-*"
+}
+
+check_sanitizer() {
+ if test -n "${CLANG_SANITIZER}"; then
+ check_logs "${1}" "*san.*" | cat
+ fi
+}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 9f1cb87eb0..b22dc4a661 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -419,7 +419,7 @@ void ui_line(ScreenGrid *grid, int row, int startcol, int endcol, int clearcol,
(const sattr_T *)grid->attrs + off);
// 'writedelay': flush & delay each time.
- if (p_wd && !(rdb_flags & RDB_COMPOSITOR)) {
+ if (p_wd && (rdb_flags & RDB_LINE)) {
// If 'writedelay' is active, set the cursor to indicate what was drawn.
ui_call_grid_cursor_goto(grid->handle, row,
MIN(clearcol, (int)grid->cols - 1));
@@ -510,6 +510,10 @@ void ui_flush(void)
pending_has_mouse = has_mouse;
}
ui_call_flush();
+
+ if (p_wd && (rdb_flags & RDB_FLUSH)) {
+ os_microdelay((uint64_t)labs(p_wd) * 1000U, true);
+ }
}
/// Check if 'mouse' is active for the current mode
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index 9140a9f1f3..e83f93eb07 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -79,6 +79,8 @@ typedef struct {
uint32_t ncalls; ///< number of calls made to the current event (plus one for the name!)
bool flushed_events; ///< events where sent to client without "flush" event
+ size_t ncells_pending; ///< total number of cells since last buffer flush
+
int hl_id; // Current highlight for legacy put event.
Integer cursor_row, cursor_col; // Intended visible cursor position.