mirror of
https://github.com/neovim/neovim.git
synced 2025-11-23 02:26:30 +00:00
Merge pull request #13434 from janlazo/vim-8.2.2076
vim-patch:8.1.{1013,1774},8.2.{1164,1673,1907,2076,2077,2078,2085,2086}
This commit is contained in:
@@ -1768,8 +1768,13 @@ au BufNewFile,BufReadPost *.tutor setf tutor
|
||||
" TWIG files
|
||||
au BufNewFile,BufReadPost *.twig setf twig
|
||||
|
||||
" Typescript
|
||||
au BufNewFile,BufReadPost *.ts setf typescript
|
||||
" Typescript or Qt translation file (which is XML)
|
||||
au BufNewFile,BufReadPost *.ts
|
||||
\ if getline(1) =~ '<?xml' |
|
||||
\ setf xml |
|
||||
\ else |
|
||||
\ setf typescript |
|
||||
\ endif
|
||||
|
||||
" TypeScript with React
|
||||
au BufNewFile,BufRead *.tsx setf typescriptreact
|
||||
|
||||
117
src/nvim/edit.c
117
src/nvim/edit.c
@@ -196,8 +196,8 @@ static int ctrl_x_mode = CTRL_X_NORMAL;
|
||||
|
||||
static int compl_matches = 0;
|
||||
static char_u *compl_pattern = NULL;
|
||||
static int compl_direction = FORWARD;
|
||||
static int compl_shows_dir = FORWARD;
|
||||
static Direction compl_direction = FORWARD;
|
||||
static Direction compl_shows_dir = FORWARD;
|
||||
static int compl_pending = 0; // > 1 for postponed CTRL-N
|
||||
static pos_T compl_startpos;
|
||||
static colnr_T compl_col = 0; /* column where the text starts
|
||||
@@ -2156,7 +2156,7 @@ static bool ins_compl_accept_char(int c)
|
||||
///
|
||||
/// @param[in] cont_s_ipos next ^X<> will set initial_pos
|
||||
int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
|
||||
int dir, bool cont_s_ipos)
|
||||
Direction dir, bool cont_s_ipos)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
char_u *str = str_arg;
|
||||
@@ -2308,7 +2308,7 @@ static int ins_compl_add(char_u *const str, int len,
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
compl_T *match;
|
||||
int dir = (cdir == kDirectionNotSet ? compl_direction : cdir);
|
||||
const Direction dir = (cdir == kDirectionNotSet ? compl_direction : cdir);
|
||||
int flags = flags_arg;
|
||||
|
||||
os_breakcheck();
|
||||
@@ -2511,7 +2511,7 @@ static void ins_compl_add_matches(int num_matches, char_u **matches, int icase)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int add_r = OK;
|
||||
int dir = compl_direction;
|
||||
Direction dir = compl_direction;
|
||||
|
||||
for (int i = 0; i < num_matches && add_r != FAIL; i++) {
|
||||
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, false, NULL, dir,
|
||||
@@ -2864,7 +2864,7 @@ ins_compl_dictionaries (
|
||||
char_u **files;
|
||||
int count;
|
||||
int save_p_scs;
|
||||
int dir = compl_direction;
|
||||
Direction dir = compl_direction;
|
||||
|
||||
if (*dict == NUL) {
|
||||
/* When 'dictionary' is empty and spell checking is enabled use
|
||||
@@ -2945,7 +2945,10 @@ theend:
|
||||
xfree(buf);
|
||||
}
|
||||
|
||||
static void ins_compl_files(int count, char_u **files, int thesaurus, int flags, regmatch_T *regmatch, char_u *buf, int *dir)
|
||||
static void ins_compl_files(int count, char_u **files, int thesaurus,
|
||||
int flags, regmatch_T *regmatch, char_u *buf,
|
||||
Direction *dir)
|
||||
FUNC_ATTR_NONNULL_ARG(2, 7)
|
||||
{
|
||||
char_u *ptr;
|
||||
int i;
|
||||
@@ -3137,6 +3140,56 @@ bool ins_compl_active(void)
|
||||
return compl_started;
|
||||
}
|
||||
|
||||
static void ins_compl_update_sequence_numbers(void)
|
||||
{
|
||||
int number = 0;
|
||||
compl_T *match;
|
||||
|
||||
if (compl_direction == FORWARD) {
|
||||
// search backwards for the first valid (!= -1) number.
|
||||
// This should normally succeed already at the first loop
|
||||
// cycle, so it's fast!
|
||||
for (match = compl_curr_match->cp_prev;
|
||||
match != NULL && match != compl_first_match;
|
||||
match = match->cp_prev) {
|
||||
if (match->cp_number != -1) {
|
||||
number = match->cp_number;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
// go up and assign all numbers which are not assigned yet
|
||||
for (match = match->cp_next;
|
||||
match != NULL && match->cp_number == -1;
|
||||
match = match->cp_next) {
|
||||
match->cp_number = ++number;
|
||||
}
|
||||
}
|
||||
} else { // BACKWARD
|
||||
assert(compl_direction == BACKWARD);
|
||||
// search forwards (upwards) for the first valid (!= -1)
|
||||
// number. This should normally succeed already at the
|
||||
// first loop cycle, so it's fast!
|
||||
for (match = compl_curr_match->cp_next;
|
||||
match != NULL && match != compl_first_match;
|
||||
match = match->cp_next) {
|
||||
if (match->cp_number != -1) {
|
||||
number = match->cp_number;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
// go down and assign all numbers which are not
|
||||
// assigned yet
|
||||
for (match = match->cp_prev;
|
||||
match && match->cp_number == -1;
|
||||
match = match->cp_prev) {
|
||||
match->cp_number = ++number;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get complete information
|
||||
void get_complete_info(list_T *what_list, dict_T *retdict)
|
||||
{
|
||||
@@ -3214,6 +3267,9 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
|
||||
}
|
||||
|
||||
if (ret == OK && (what_flag & CI_WHAT_SELECTED)) {
|
||||
if (compl_curr_match != NULL && compl_curr_match->cp_number == -1) {
|
||||
ins_compl_update_sequence_numbers();
|
||||
}
|
||||
ret = tv_dict_add_nr(retdict, S_LEN("selected"),
|
||||
(compl_curr_match != NULL)
|
||||
? compl_curr_match->cp_number - 1 : -1);
|
||||
@@ -3865,7 +3921,7 @@ theend:
|
||||
*/
|
||||
static void ins_compl_add_list(list_T *const list)
|
||||
{
|
||||
int dir = compl_direction;
|
||||
Direction dir = compl_direction;
|
||||
|
||||
// Go through the List with matches and add each of them.
|
||||
TV_LIST_ITER(list, li, {
|
||||
@@ -5242,52 +5298,11 @@ static int ins_complete(int c, bool enable_pum)
|
||||
} else if (compl_curr_match->cp_next == compl_curr_match->cp_prev) {
|
||||
edit_submode_extra = (char_u *)_("The only match");
|
||||
edit_submode_highl = HLF_COUNT;
|
||||
compl_curr_match->cp_number = 1;
|
||||
} else {
|
||||
// Update completion sequence number when needed.
|
||||
if (compl_curr_match->cp_number == -1) {
|
||||
int number = 0;
|
||||
compl_T *match;
|
||||
|
||||
if (compl_direction == FORWARD) {
|
||||
/* search backwards for the first valid (!= -1) number.
|
||||
* This should normally succeed already at the first loop
|
||||
* cycle, so it's fast! */
|
||||
for (match = compl_curr_match->cp_prev; match != NULL
|
||||
&& match != compl_first_match;
|
||||
match = match->cp_prev)
|
||||
if (match->cp_number != -1) {
|
||||
number = match->cp_number;
|
||||
break;
|
||||
}
|
||||
if (match != NULL)
|
||||
/* go up and assign all numbers which are not assigned
|
||||
* yet */
|
||||
for (match = match->cp_next;
|
||||
match != NULL && match->cp_number == -1;
|
||||
match = match->cp_next)
|
||||
match->cp_number = ++number;
|
||||
} else { // BACKWARD
|
||||
// search forwards (upwards) for the first valid (!= -1)
|
||||
// number. This should normally succeed already at the
|
||||
// first loop cycle, so it's fast!
|
||||
for (match = compl_curr_match->cp_next;
|
||||
match != NULL && match != compl_first_match;
|
||||
match = match->cp_next) {
|
||||
if (match->cp_number != -1) {
|
||||
number = match->cp_number;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match != NULL) {
|
||||
// go down and assign all numbers which are not
|
||||
// assigned yet
|
||||
for (match = match->cp_prev;
|
||||
match && match->cp_number == -1;
|
||||
match = match->cp_prev) {
|
||||
match->cp_number = ++number;
|
||||
}
|
||||
}
|
||||
}
|
||||
ins_compl_update_sequence_numbers();
|
||||
}
|
||||
|
||||
/* The match should always have a sequence number now, this is
|
||||
|
||||
@@ -1711,8 +1711,11 @@ void msg_prt_line(char_u *s, int list)
|
||||
} else if ((l = utfc_ptr2len(s)) > 1) {
|
||||
col += utf_ptr2cells(s);
|
||||
char buf[MB_MAXBYTES + 1];
|
||||
if (curwin->w_p_lcs_chars.nbsp != NUL && list
|
||||
&& (utf_ptr2char(s) == 160 || utf_ptr2char(s) == 0x202f)) {
|
||||
if (l >= MB_MAXBYTES) {
|
||||
xstrlcpy(buf, "¿", sizeof(buf));
|
||||
} else if (curwin->w_p_lcs_chars.nbsp != NUL && list
|
||||
&& (utf_ptr2char(s) == 160
|
||||
|| utf_ptr2char(s) == 0x202f)) {
|
||||
utf_char2bytes(curwin->w_p_lcs_chars.nbsp, (char_u *)buf);
|
||||
buf[utfc_ptr2len((char_u *)buf)] = NUL;
|
||||
} else {
|
||||
|
||||
@@ -89,7 +89,7 @@ static struct spat spats[2] =
|
||||
static int last_idx = 0; /* index in spats[] for RE_LAST */
|
||||
|
||||
static char_u lastc[2] = { NUL, NUL }; // last character searched for
|
||||
static int lastcdir = FORWARD; // last direction of character search
|
||||
static Direction lastcdir = FORWARD; // last direction of character search
|
||||
static int last_t_cmd = true; // last search t_cmd
|
||||
static char_u lastc_bytes[MB_MAXBYTES + 1];
|
||||
static int lastc_bytelen = 1; // >1 for multi-byte char
|
||||
@@ -437,7 +437,7 @@ void set_last_csearch(int c, char_u *s, int len)
|
||||
memset(lastc_bytes, 0, sizeof(lastc_bytes));
|
||||
}
|
||||
|
||||
void set_csearch_direction(int cdir)
|
||||
void set_csearch_direction(Direction cdir)
|
||||
{
|
||||
lastcdir = cdir;
|
||||
}
|
||||
@@ -1430,7 +1430,7 @@ end_do_search:
|
||||
* ADDING is set. If p_ic is set then the pattern must be in lowercase.
|
||||
* Return OK for success, or FAIL if no line found.
|
||||
*/
|
||||
int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat)
|
||||
int search_for_exact_line(buf_T *buf, pos_T *pos, Direction dir, char_u *pat)
|
||||
{
|
||||
linenr_T start = 0;
|
||||
char_u *ptr;
|
||||
@@ -1496,10 +1496,11 @@ int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat)
|
||||
* Return FAIL or OK.
|
||||
*/
|
||||
int searchc(cmdarg_T *cap, int t_cmd)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
int c = cap->nchar; /* char to search for */
|
||||
int dir = cap->arg; /* TRUE for searching forward */
|
||||
long count = cap->count1; /* repeat count */
|
||||
int c = cap->nchar; // char to search for
|
||||
Direction dir = cap->arg; // TRUE for searching forward
|
||||
long count = cap->count1; // repeat count
|
||||
int col;
|
||||
char_u *p;
|
||||
int len;
|
||||
@@ -4462,7 +4463,7 @@ static void search_stat(int dirc, pos_T *pos,
|
||||
void
|
||||
find_pattern_in_path(
|
||||
char_u *ptr, // pointer to search pattern
|
||||
int dir, // direction of expansion
|
||||
Direction dir, // direction of expansion
|
||||
size_t len, // length of search pattern
|
||||
bool whole, // match whole words only
|
||||
bool skip_comments, // don't match inside comments
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
/* for offsetof() */
|
||||
#include <stddef.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/ascii.h"
|
||||
#include "nvim/spell.h"
|
||||
#include "nvim/buffer.h"
|
||||
@@ -6653,7 +6652,7 @@ void
|
||||
spell_dump_compl (
|
||||
char_u *pat, // leading part of the word
|
||||
int ic, // ignore case
|
||||
int *dir, // direction for adding matches
|
||||
Direction *dir, // direction for adding matches
|
||||
int dumpflags_arg // DUMPFLAG_*
|
||||
)
|
||||
{
|
||||
@@ -6820,7 +6819,9 @@ spell_dump_compl (
|
||||
|
||||
// Dumps one word: apply case modifications and append a line to the buffer.
|
||||
// When "lnum" is zero add insert mode completion.
|
||||
static void dump_word(slang_T *slang, char_u *word, char_u *pat, int *dir, int dumpflags, int wordflags, linenr_T lnum)
|
||||
static void dump_word(slang_T *slang, char_u *word, char_u *pat,
|
||||
Direction *dir, int dumpflags, int wordflags,
|
||||
linenr_T lnum)
|
||||
{
|
||||
bool keepcap = false;
|
||||
char_u *p;
|
||||
@@ -6906,7 +6907,7 @@ dump_prefixes (
|
||||
slang_T *slang,
|
||||
char_u *word, // case-folded word
|
||||
char_u *pat,
|
||||
int *dir,
|
||||
Direction *dir,
|
||||
int dumpflags,
|
||||
int flags, // flags with prefix ID
|
||||
linenr_T startlnum
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "nvim/spell_defs.h"
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/vim.h"
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "spell.h.generated.h"
|
||||
|
||||
@@ -471,7 +471,6 @@ let s:filename_checks = {
|
||||
\ 'tssgm': ['file.tssgm'],
|
||||
\ 'tssop': ['file.tssop'],
|
||||
\ 'twig': ['file.twig'],
|
||||
\ 'typescript': ['file.ts'],
|
||||
\ 'typescriptreact': ['file.tsx'],
|
||||
\ 'uc': ['file.uc'],
|
||||
\ 'udevconf': ['/etc/udev/udev.conf'],
|
||||
@@ -668,5 +667,22 @@ func Test_hook_file()
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
func Test_ts_file()
|
||||
filetype on
|
||||
|
||||
call writefile(['<?xml version="1.0" encoding="utf-8"?>'], 'Xfile.ts')
|
||||
split Xfile.ts
|
||||
call assert_equal('xml', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['// looks like Typescript'], 'Xfile.ts')
|
||||
split Xfile.ts
|
||||
call assert_equal('typescript', &filetype)
|
||||
bwipe!
|
||||
|
||||
call delete('Xfile.hook')
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -312,6 +312,24 @@ func Test_completefunc_args()
|
||||
delfunc CompleteFunc
|
||||
endfunc
|
||||
|
||||
func CompleteTest(findstart, query)
|
||||
if a:findstart
|
||||
return col('.')
|
||||
endif
|
||||
return ['matched']
|
||||
endfunc
|
||||
|
||||
func Test_completefunc_info()
|
||||
new
|
||||
set completeopt=menuone
|
||||
set completefunc=CompleteTest
|
||||
call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
|
||||
call assert_equal("matched{'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
|
||||
bwipe!
|
||||
set completeopt&
|
||||
set completefunc&
|
||||
endfunc
|
||||
|
||||
" Check that when using feedkeys() typeahead does not interrupt searching for
|
||||
" completions.
|
||||
func Test_compl_feedkeys()
|
||||
|
||||
@@ -103,3 +103,14 @@ func Test_list2str_str2list_latin1()
|
||||
call assert_equal(l, lres)
|
||||
call assert_equal(s, sres)
|
||||
endfunc
|
||||
|
||||
func Test_print_overlong()
|
||||
" Text with more composing characters than MB_MAXBYTES.
|
||||
new
|
||||
call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
||||
s/x/\=nr2char(1629)/g
|
||||
print
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user