aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/arabic.c2
-rw-r--r--src/nvim/autocmd.c7
-rw-r--r--src/nvim/buffer_updates.c1
-rw-r--r--src/nvim/context.c2
-rw-r--r--src/nvim/cursor_shape.c3
-rw-r--r--src/nvim/diff.c2
-rw-r--r--src/nvim/digraph.c2
-rw-r--r--src/nvim/ex_docmd.c9
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/syntax.c4
-rw-r--r--src/nvim/testdir/test_filetype.vim23
-rw-r--r--src/nvim/testdir/test_syntax.vim13
-rw-r--r--src/nvim/tui/tui.c19
13 files changed, 66 insertions, 23 deletions
diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c
index 5dcc3d3d0d..db78e0e68f 100644
--- a/src/nvim/arabic.c
+++ b/src/nvim/arabic.c
@@ -974,6 +974,7 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c)
/// @param one First character.
/// @param two Character just after "one".
bool arabic_combine(int one, int two)
+ FUNC_ATTR_PURE
{
if (one == a_LAM) {
return arabic_maycombine(two);
@@ -984,6 +985,7 @@ bool arabic_combine(int one, int two)
/// Check whether we are dealing with a character that could be regarded as an
/// Arabic combining character, need to check the character before this.
bool arabic_maycombine(int two)
+ FUNC_ATTR_PURE
{
if (p_arshape && !p_tbidi) {
return two == a_ALEF_MADDA
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 1b146f82c6..77d4115b59 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -379,6 +379,7 @@ static void au_cleanup(void)
// Get the first AutoPat for a particular event.
AutoPat *au_get_autopat_for_event(event_T event)
+ FUNC_ATTR_PURE
{
return first_autopat[(int)event];
}
@@ -1143,6 +1144,7 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
}
size_t aucmd_pattern_length(char_u *pat)
+ FUNC_ATTR_PURE
{
if (*pat == NUL) {
return 0;
@@ -1175,6 +1177,7 @@ size_t aucmd_pattern_length(char_u *pat)
}
char_u *aucmd_next_pattern(char_u *pat, size_t patlen)
+ FUNC_ATTR_PURE
{
pat = pat + patlen;
if (*pat == ',') {
@@ -2383,6 +2386,7 @@ theend:
// Checks if a pattern is buflocal
bool aupat_is_buflocal(char_u *pat, int patlen)
+ FUNC_ATTR_PURE
{
return patlen >= 8
&& STRNCMP(pat, "<buffer", 7) == 0
@@ -2492,6 +2496,7 @@ char *aucmd_exec_default_desc(AucmdExecutable acc)
}
char *aucmd_exec_to_string(AutoCmd *ac, AucmdExecutable acc)
+ FUNC_ATTR_PURE
{
switch (acc.type) {
case CALLABLE_EX:
@@ -2542,6 +2547,7 @@ AucmdExecutable aucmd_exec_copy(AucmdExecutable src)
}
bool aucmd_exec_is_deleted(AucmdExecutable acc)
+ FUNC_ATTR_PURE
{
switch (acc.type) {
case CALLABLE_EX:
@@ -2556,6 +2562,7 @@ bool aucmd_exec_is_deleted(AucmdExecutable acc)
}
bool au_event_is_empty(event_T event)
+ FUNC_ATTR_PURE
{
return first_autopat[event] == NULL;
}
diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c
index ee1b7ebc95..3e2d04b3a2 100644
--- a/src/nvim/buffer_updates.c
+++ b/src/nvim/buffer_updates.c
@@ -84,6 +84,7 @@ bool buf_updates_register(buf_T *buf, uint64_t channel_id, BufUpdateCallbacks cb
}
bool buf_updates_active(buf_T *buf)
+ FUNC_ATTR_PURE
{
return kv_size(buf->update_channels) || kv_size(buf->update_callbacks);
}
diff --git a/src/nvim/context.c b/src/nvim/context.c
index 9434b4e0ea..c30a05a3c8 100644
--- a/src/nvim/context.c
+++ b/src/nvim/context.c
@@ -33,6 +33,7 @@ void ctx_free_all(void)
/// Returns the size of the context stack.
size_t ctx_size(void)
+ FUNC_ATTR_PURE
{
return kv_size(ctx_stack);
}
@@ -40,6 +41,7 @@ size_t ctx_size(void)
/// Returns pointer to Context object with given zero-based index from the top
/// of context stack or NULL if index is out of bounds.
Context *ctx_get(size_t index)
+ FUNC_ATTR_PURE
{
if (index < kv_size(ctx_stack)) {
return &kv_Z(ctx_stack, index);
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 0e4a4bcfb0..73adff6579 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -277,6 +277,7 @@ char *parse_shape_opt(int what)
///
/// @param exclusive If 'selection' option is "exclusive".
bool cursor_is_block_during_visual(bool exclusive)
+ FUNC_ATTR_PURE
{
int mode_idx = exclusive ? SHAPE_IDX_VE : SHAPE_IDX_V;
return (SHAPE_BLOCK == shape_table[mode_idx].shape
@@ -300,6 +301,7 @@ int cursor_mode_str2int(const char *mode)
/// Check if a syntax id is used as a cursor style.
bool cursor_mode_uses_syn_id(int syn_id)
+ FUNC_ATTR_PURE
{
if (*p_guicursor == NUL) {
return false;
@@ -316,6 +318,7 @@ bool cursor_mode_uses_syn_id(int syn_id)
/// Return the index into shape_table[] for the current mode.
int cursor_get_mode_idx(void)
+ FUNC_ATTR_PURE
{
if (State == SHOWMATCH) {
return SHAPE_IDX_SM;
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 0b55fb877c..9e8fa2e62d 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -883,6 +883,7 @@ theend:
/// diff will be used anyway.
///
int diff_internal(void)
+ FUNC_ATTR_PURE
{
return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL;
}
@@ -2250,6 +2251,7 @@ bool diffopt_horizontal(void)
// Return true if 'diffopt' contains "hiddenoff".
bool diffopt_hiddenoff(void)
+ FUNC_ATTR_PURE
{
return (diff_flags & DIFF_HIDDEN_OFF) != 0;
}
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 083c868607..0e148543aa 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1551,6 +1551,7 @@ int get_digraph(bool cmdline)
/// @return If no match, return "char2". If "meta_char" is true and "char1"
// is a space, return "char2" | 0x80.
static int getexactdigraph(int char1, int char2, bool meta_char)
+ FUNC_ATTR_PURE
{
int retval = 0;
@@ -1601,6 +1602,7 @@ static int getexactdigraph(int char1, int char2, bool meta_char)
///
/// @return The digraph.
int digraph_get(int char1, int char2, bool meta_char)
+ FUNC_ATTR_PURE
{
int retval;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index cbfe6e3789..fc0bb48803 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2373,8 +2373,13 @@ int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent)
switch (eap->addr_type) {
case ADDR_LINES:
case ADDR_OTHER:
- // default is current line number
- eap->line2 = curwin->w_cursor.lnum;
+ // Default is the cursor line number. Avoid using an invalid
+ // line number though.
+ if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count) {
+ eap->line2 = curbuf->b_ml.ml_line_count;
+ } else {
+ eap->line2 = curwin->w_cursor.lnum;
+ }
break;
case ADDR_WINDOWS:
eap->line2 = CURRENT_WIN_NR;
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 49bd8e7b21..91e93a236a 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2604,6 +2604,7 @@ char_u *getexline(int c, void *cookie, int indent, bool do_concat)
}
bool cmdline_overstrike(void)
+ FUNC_ATTR_PURE
{
return ccline.overstrike;
}
@@ -2611,6 +2612,7 @@ bool cmdline_overstrike(void)
/// Return true if the cursor is at the end of the cmdline.
bool cmdline_at_end(void)
+ FUNC_ATTR_PURE
{
return (ccline.cmdpos >= ccline.cmdlen);
}
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index d884ad704b..0ceb66f438 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -5802,8 +5802,8 @@ char_u *get_syntax_name(expand_T *xp, int idx)
int syn_get_id(win_T *wp, long lnum, colnr_T col, int trans, bool *spellp, int keep_state)
{
// When the position is not after the current position and in the same
- // line of the same buffer, need to restart parsing.
- if (wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) {
+ // line of the same window with the same buffer, need to restart parsing.
+ if (wp != syn_win || wp->w_buffer != syn_buf || lnum != current_lnum || col < current_col) {
syntax_start(wp, lnum);
} else if (col > current_col) {
// next_match may not be correct when moving around, e.g. with the
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 85d9a75824..bf6226c6b3 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -113,7 +113,7 @@ let s:filename_checks = {
\ 'cobol': ['file.cbl', 'file.cob', 'file.lib'],
\ 'coco': ['file.atg'],
\ 'conaryrecipe': ['file.recipe'],
- \ 'conf': ['auto.master'],
+ \ 'conf': ['/etc/pacman.conf', 'any/etc/pacman.conf', 'auto.master'],
\ 'config': ['configure.in', 'configure.ac', '/etc/hostname.file'],
\ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],
\ 'cook': ['file.cook'],
@@ -152,7 +152,7 @@ let s:filename_checks = {
\ 'dnsmasq': ['/etc/dnsmasq.conf', '/etc/dnsmasq.d/file', 'any/etc/dnsmasq.conf', 'any/etc/dnsmasq.d/file'],
\ 'dockerfile': ['Containerfile', 'Dockerfile', 'file.Dockerfile', 'Dockerfile.debian', 'Containerfile.something'],
\ 'dosbatch': ['file.bat'],
- \ 'dosini': ['.editorconfig', '/etc/pacman.conf', '/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/pacman.conf', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap'],
+ \ 'dosini': ['.editorconfig', '/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap'],
\ 'dot': ['file.dot', 'file.gv'],
\ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'],
\ 'dtd': ['file.dtd'],
@@ -383,6 +383,7 @@ let s:filename_checks = {
\ 'omnimark': ['file.xom', 'file.xin'],
\ 'opam': ['opam', 'file.opam', 'file.opam.template'],
\ 'openroad': ['file.or'],
+ \ 'openscad': ['file.scad'],
\ 'ora': ['file.ora'],
\ 'org': ['file.org', 'file.org_archive'],
\ 'pamconf': ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf', 'any/etc/pam.d/file'],
@@ -743,7 +744,7 @@ func Test_setfiletype_completion()
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""
-" Tests for specific extentions and filetypes.
+" Tests for specific extensions and filetypes.
" Keep sorted.
"""""""""""""""""""""""""""""""""""""""""""""""""
@@ -1171,12 +1172,12 @@ func Test_hook_file()
call writefile(['[Trigger]', 'this is pacman config'], 'Xfile.hook')
split Xfile.hook
- call assert_equal('dosini', &filetype)
+ call assert_equal('conf', &filetype)
bwipe!
call writefile(['not pacman'], 'Xfile.hook')
split Xfile.hook
- call assert_notequal('dosini', &filetype)
+ call assert_notequal('conf', &filetype)
bwipe!
call delete('Xfile.hook')
@@ -1535,11 +1536,13 @@ func Test_src_file()
bwipe!
call delete('srcfile.Src')
- " KRL global def with embedded spaces, file starts with empty line(s).
- call writefile(['', 'global def srcfile()'], 'srcfile.SRC')
- split srcfile.SRC
- call assert_equal('krl', &filetype)
- bwipe!
+ " KRL global deffct with embedded spaces, file starts with empty line(s).
+ for text in ['global def srcfile()', 'global deffct srcfile()']
+ call writefile(['', text], 'srcfile.SRC')
+ split srcfile.SRC
+ call assert_equal('krl', &filetype, text)
+ bwipe!
+ endfor
" User may overrule file inspection
let g:filetype_src = 'src'
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index b047b53b6f..6bef61ae8f 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -794,5 +794,18 @@ func Test_syn_include_contains_TOP()
bw!
endfunc
+" This was using freed memory
+func Test_WinEnter_synstack_synID()
+ autocmd WinEnter * call synstack(line("."), col("."))
+ autocmd WinEnter * call synID(line('.'), col('.') - 1, 1)
+ call setline(1, 'aaaaa')
+ normal! $
+ new
+ close
+
+ au! WinEnter
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index a67bcf98dc..4b5ad4cff8 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -311,8 +311,7 @@ static void terminfo_start(UI *ui)
// Enable bracketed paste
unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste);
- // Enable extended keys (also known as 'modifyOtherKeys' or CSI u). On terminals that don't
- // support this, this sequence is ignored.
+ // Enable extended keys (also known as 'modifyOtherKeys' or CSI u)
unibi_out_ext(ui, data->unibi_ext.enable_extended_keys);
int ret;
@@ -2075,13 +2074,15 @@ static void augment_terminfo(TUIData *data, const char *term, long vte_version,
"\x1b[58:2::%p1%d:%p2%d:%p3%dm");
}
- if (!kitty) {
- // Kitty does not support these sequences; it only supports it's own CSI > 1 u which enables the
- // Kitty keyboard protocol
- data->unibi_ext.enable_extended_keys = (int)unibi_add_ext_str(ut, "ext.enable_extended_keys",
- "\x1b[>4;2m");
- data->unibi_ext.disable_extended_keys = (int)unibi_add_ext_str(ut, "ext.disable_extended_keys",
- "\x1b[>4;0m");
+ data->unibi_ext.enable_extended_keys = unibi_find_ext_str(ut, "Eneks");
+ data->unibi_ext.disable_extended_keys = unibi_find_ext_str(ut, "Dseks");
+ if (data->unibi_ext.enable_extended_keys == -1) {
+ if (!kitty && (vte_version == 0 || vte_version >= 5400)) {
+ data->unibi_ext.enable_extended_keys = (int)unibi_add_ext_str(ut, "ext.enable_extended_keys",
+ "\x1b[>4;2m");
+ data->unibi_ext.disable_extended_keys = (int)unibi_add_ext_str(ut, "ext.disable_extended_keys",
+ "\x1b[>4m");
+ }
}
}