summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
AgeCommit message (Collapse)Author
2024-03-31patch 9.1.0231: Filetype may be undetected when SwapExists sets ft in other bufv9.1.0231zeertzjq
Problem: Filetype may be undetected when a SwapExists autocommand sets filetype in another buffer. Solution: Make filetype detection state buffer-specific. Also fix a similar problem for 'modified' (zeertzjq). closes: #14344 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-12patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()v9.1.0172zeertzjq
Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: #14183 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-03patch 9.1.0147: Cannot keep a buffer focused in a windowv9.1.0147Colin Kennedy
Problem: Cannot keep a buffer focused in a window (Amit Levy) Solution: Add the 'winfixbuf' window-local option (Colin Kennedy) fixes: #6445 closes: #13903 Signed-off-by: Colin Kennedy <colinvfx@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-28patch 9.1.0143: [security]: autocmd causes use-after-free in set_curbuf()v9.1.0143Christian Brabandt
Problem: [security]: autocmd cause use-after-free in set_curbuf() (kawarimidoll) Solution: check side-effect of BufLeave autocommand, when the number of windows changed, close windows containing buffers that will be wiped, if curbuf changed unexpectedly make sure b_nwindows is decremented otherwise it cannot be wiped set_curbuf() already makes some efforts to ensure the BufLeave autocommands do not cause issues. However there are still 2 issues that are not taken care of: 1) If a BufLeave autocommand opens a new window containing the same buffer as that is going got be closed in close_buffer() a bit later, we suddenly have another window open, containing a free'd buffer. So we must check if the number of windows changed and if it does (and the current buffer is going to be wiped (according to the 'bufhidden' setting), let's immediately close all windows containing the current buffer using close_windows() 2) If a BufLeave autocommand changes our current buffer (displays it in the current window), buf->b_nwindow will be incremented. As part of set_curbuf() we will however enter another buffer soon, which means, the newly created curbuf will have b_nwindows still have set, even so the buffer is no longer displayed in a window. This causes later problems, because it will no longer be possible to wipe such a buffer. So just before entering the final buffer, check if the curbuf changed when calling the BufLeave autocommand and if it does (and curbuf is still valid), decrement curbuf->b_nwindows. Both issues can be verified using the provided test (however the second issue only because such an impacted buffer won't be wiped, causing futher issues in later tests). fixes: #13839 closes: #14104 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24patch 9.1.0131: buffer-completion may not always find all matchesv9.1.0131Christian Brabandt
Problem: buffer-completion code too complicated and does not always find all matches (irisjae) Solution: do not try to anchor pattern to beginning of line or directory-separator, always return all matches Note: we are considering the non-fuzzy buffer-matching here. Currently, the buffer-completion code makes 2 attempts to match a pattern against the list of available patterns. First try is to match the pattern and anchor it to either the beginning of the file name or at a directory-separator (// or \\). When a match is found, Vim returns the matching buffers and does not try to find a match anywhere within a buffer name. So if you have opened two buffers like /tmp/Foobar.c and /tmp/MyFoobar.c using `:b Foo` will only complete to the first filename, but not the second (the same happens with `getcompletion('Foo', 'buffer')`). It may make sense, that completion priorities buffer names at directory boundaries, but it inconsistent, may cause confusion why a certain buffer name is not completed when typing `:b Foo<C-D>` which returns only a single file name and then pressing Enter (to switch to that buffer), Vim will error with 'E93: More than one match for Foo'). Similar things may happen when wiping the /tmp/Foobar.c pattern and afterwards the completion starts completing other buffers. So let's simplify the code and always match the pattern anywhere in the buffer name, do not try to favor matches at directory boundaries. This is also simplifies the code a bit, we do not need to run over the list of buffers several times, but only twice. fixes #13894 closes: #14082 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-15patch 9.1.0113: duplicate code when cleaning undo stackv9.1.0113Christian Brabandt
Problem: duplicate code when cleaning undo stack Solution: refactor undo cleanup into a single public function related: #13928 Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-23patch 9.1.0049: Make "[Command Line]" a special buffer namev9.1.0049Sean Dewar
Problem: E95 is possible if a buffer called "[Command Line]" already exists when opening the cmdwin. This can also happen if the cmdwin's buffer could not be deleted when closing. Solution: Un-name the cmdwin buffer, and give it a special name instead, similar to what's done for quickfix buffers and for unnamed prompt and scratch buffers. As a result, BufFilePre/Post are no longer fired when opening the cmdwin. Add a "command" key to the dictionary returned by getbufinfo() to differentiate the cmdwin buffer instead. (Sean Dewar) NOTE: This is technically a breaking change... maybe this needs a different solution? (Or maybe this issue can be ignored...) A GitHub search reveals some plugins expect the old behaviour. However, many of those plugins also do not seem to account for the string being translated, so they are subtly broken anyway (not withstanding the fact that you can call any old buffer "[Command Line]" too...) closes: #12819 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-04patch 9.1.0006: is*() and to*() function may be unsafev9.1.0006Keith Thompson
Problem: is*() and to*() function may be unsafe Solution: Add SAFE_* macros and start using those instead (Keith Thompson) Use SAFE_() macros for is*() and to*() functions The standard is*() and to*() functions declared in <ctype.h> have undefined behavior for negative arguments other than EOF. If plain char is signed, passing an unchecked value from argv for from user input to one of these functions has undefined behavior. Solution: Add SAFE_*() macros that cast the argument to unsigned char. Most implementations behave sanely for negative arguments, and most character values in practice are non-negative, but it's still best to avoid undefined behavior. The change from #13347 has been omitted, as this has already been separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a (v9.0.2054) fixes: #13332 closes: #13347 Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-11patch 9.0.2010: [security] use-after-free from buf_contents_changed()v9.0.2010Christian Brabandt
Problem: [security] use-after-free from buf_contents_changed() Solution: block autocommands Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-03patch 9.0.1859: heap-use-after-free in bt_normal()v9.0.1859Christian Brabandt
Problem: heap-use-after-free in bt_normal() Solution: check that buffer is still valid Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-07-01patch 9.0.1672: tabline highlight wrong after truncated double width labelv9.0.1672zeertzjq
Problem: Tabline highlight wrong after truncated double width label. Solution: Fill up half a double width character later. (closes #12614)
2023-05-27patch 9.0.1583: get E304 when using 'cryptmethod' "xchacha20v2"v9.0.1583Bram Moolenaar
Problem: Get E304 when using 'cryptmethod' "xchacha20v2". (Steve Mynott) Solution: Add 4th crypt method to block zero ID check. Avoid syncing a swap file before reading the file. (closes #12433)
2023-05-23patch 9.0.1575: "file N of M" message is not translatedv9.0.1575Bram Moolenaar
Problem: "file N of M" message is not translated. Solution: Make argument count message translatable. (close #12429)
2023-05-20patch 9.0.1571: RedrawingDisabled not used consistentlyv9.0.1571Bram Moolenaar
Problem: RedrawingDisabled not used consistently. Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in win_split_ins(). (closes #11961)
2023-05-14patch 9.0.1554: code for handling 'switchbuf' is repeatedv9.0.1554Yegappan Lakshmanan
Problem: Code for handling 'switchbuf' is repeated. Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan, closes #12397)
2023-05-12patch 9.0.1546: some commands for opening a file don't use 'switchbuf'v9.0.1546Yegappan Lakshmanan
Problem: Some commands for opening a file don't use 'switchbuf'. Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan, closes #12383, closes #12381)
2023-04-29patch 9.0.1497: the ruler percentage can't be localizedv9.0.1497Emir SARI
Problem: The ruler percentage can't be localized. Solution: Use a string that can be translated. (Emir Sari, closes #12311)
2023-04-23patch 9.0.1481: decrypting with libsodium may fail if the library changesv9.0.1481Christian Brabandt
Problem: Decrypting with libsodium may fail if the library changes. Solution: Add parameters used to the encrypted file header. (Christian Brabandt, closes #12279)
2023-04-15patch 9.0.1454: code indenting is confused by macrosv9.0.1454ichizok
Problem: Code indenting is confused by macros. Solution: Put semicolon after the macros instead of inside. (Ozaki Kiichi, closes #12257)
2023-03-07patch 9.0.1391: "clear" macros are not always usedv9.0.1391Yegappan Lakshmanan
Problem: "clear" macros are not always used. Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more places. (Yegappan Lakshmanan, closes #12104)
2023-02-20patch 9.0.1331: illegal memory access when using :ball in Visual modev9.0.1331Pavel Mayorov
Problem: Illegal memory access when using :ball in Visual mode. Solution: Stop Visual mode when using :ball. (Pavel Mayorov, closes #11923)
2023-02-20patch 9.0.1330: handling new value of an option has a long "else if" chainv9.0.1330Yegappan Lakshmanan
Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes #12015)
2023-02-14patch 9.0.1309: scrolling two lines with even line count and 'scrolloff' setv9.0.1309Bram Moolenaar
Problem: Scrolling two lines with even line count and 'scrolloff' set. Solution: Adjust how the topline is computed. (closes #10545)
2023-02-11patch 9.0.1300: 'statusline' only supports one "%=" itemv9.0.1300Yegappan Lakshmanan
Problem: 'statusline' only supports one "%=" item. Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan Lakshmanan, closes #11970, closes #11965)
2023-01-09patch 9.0.1166: code is indented more than necessaryv9.0.1166Yegappan Lakshmanan
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11792)
2023-01-04patch 9.0.1143: invalid memory access with bad 'statusline' valuev9.0.1143Bram Moolenaar
Problem: Invalid memory access with bad 'statusline' value. Solution: Avoid going over the NUL at the end.
2023-01-02patch 9.0.1132: code is indented more than neededv9.0.1132Yegappan Lakshmanan
Problem: Code is indented more than needed. Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan, closes #11769)
2022-12-15patch 9.0.1061: cannot display 'showcmd' somewhere elsev9.0.1061Luuk van Baal
Problem: Cannot display 'showcmd' somewhere else. Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes #11684)
2022-11-28patch 9.0.0965: using one window for executing autocommands is insufficientv9.0.0965Bram Moolenaar
Problem: Using one window for executing autocommands is insufficient. Solution: Use up to five windows for executing autocommands.
2022-11-25patch 9.0.0949: crash when unletting a variable while listing variablesv9.0.0949Bram Moolenaar
Problem: Crash when unletting a variable while listing variables. Solution: Disallow changing a hashtable while going over the entries. (closes #11435)
2022-11-07patch 9.0.0844: handling 'statusline' errors is spread outv9.0.0844Luuk van Baal
Problem: Handling 'statusline' errors is spread out. Solution: Pass the option name to the lower levels so the option can be reset there when an error is encountered. (Luuk van Baal, closes #11467)
2022-10-29patch 9.0.0819v9.0.0819Bram Moolenaar
2022-10-18patch 9.0.0789: dummy buffer ends up in a windowv9.0.0789Bram Moolenaar
Problem: Dummy buffer ends up in a window. Solution: Disallow navigating to a dummy buffer.
2022-10-15patch 9.0.0761: cannot use 'indentexpr' for Lisp indentingv9.0.0761Bram Moolenaar
Problem: Cannot use 'indentexpr' for Lisp indenting. Solution: Add the 'lispoptions' option.
2022-10-13patch 9.0.0747: too many #ifdefsv9.0.0747Martin Tournoij
Problem: Too many #ifdefs. Solution: Gradudate the +cmdline_info feature. (Martin Tournoij, closes #11330)
2022-10-10patch 9.0.0710: quitting/unloading/hiding a terminal does not work properlyv9.0.0710Yee Cheng Chin
Problem: Quitting/unloading/hiding a terminal buffer does not always work properly. Solution: Avoid that ":q!" leaves an empty buffer behind. ":bunload!" also kills the job and unloads the buffer. ":hide" does not unload the buffer. (Yee Cheng Chin, closes #11323)
2022-10-09patch 9.0.0708: :confirm does not work properly for a terminal bufferv9.0.0708Yee Cheng Chin
Problem: :confirm does not work properly for a terminal buffer. Solution: Handle :confirm for a terminal buffer differently. (Yee Cheng Chin, closes #11312)
2022-10-01patch 9.0.0634: evaluating "expr" options has more overhead than neededv9.0.0634Bram Moolenaar
Problem: Evaluating "expr" options has more overhead than needed. Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr', "expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr', 'formatexpr', 'indentexpr' and 'charconvert'.
2022-09-28patch 9.0.0614: SpellFileMissing autocmd may delete bufferv9.0.0614Bram Moolenaar
Problem: SpellFileMissing autocmd may delete buffer. Solution: Disallow deleting the current buffer to avoid using freed memory.
2022-08-26patch 9.0.0274: netrw plugin does not show remote filesv9.0.0274Bram Moolenaar
Problem: Netrw plugin does not show remote files. Solution: Do read a file when 'buftype' is "acwrite". (closes #10983)
2022-08-26patch 9.0.0272: BufReadCmd not triggered when loading a "nofile" bufferv9.0.0272Bram Moolenaar
Problem: BufReadCmd not triggered when loading a "nofile" buffer. (Maxim Kim) Solution: Call readfile() but bail out before reading a file. (closes #10983)
2022-08-25patch 9.0.0266: compiler warning for unused argumentv9.0.0266Bram Moolenaar
Problem: Compiler warning for unused argument. Solution: Add UNUSED.
2022-08-25patch 9.0.0265: no good reason why the "gf" command isn't in the tiny versionv9.0.0265Bram Moolenaar
Problem: No good reason why the "gf" command is not in the tiny version. Solution: Graduate the file_in_path feature.
2022-08-25patch 9.0.0263: too many #ifdefsv9.0.0263Bram Moolenaar
Problem: Too many #ifdefs. Solution: Make some functions always available.
2022-08-25patch 9.0.0262: build failure without the +quickfix featurev9.0.0262Bram Moolenaar
Problem: Build failure without the +quickfix feature. Solution: Add #ifdef.
2022-08-25patch 9.0.0261: bufload() reads a file even if the name is not a file namev9.0.0261Bram Moolenaar
Problem: bufload() reads a file even if the name is not a file name. (Cyker Way) Solution: Do not read the file when the buffer name is not a file name. (closes #10975)
2022-08-22patch 9.0.0245: mechanism to prevent recursive screen updating is incompletev9.0.0245Bram Moolenaar
Problem: Mechanism to prevent recursive screen updating is incomplete. Solution: Add "redraw_not_allowed" and set it in build_stl_str_hl(). (issue #10952)
2022-08-16patch 9.0.0222: no good reason why text objects are only in larger buildsv9.0.0222Bram Moolenaar
Problem: No good reason why text objects are only in larger builds. Solution: Graduate +textobjects.
2022-08-14patch 9.0.0206: redraw flags are not named specificallyv9.0.0206Bram Moolenaar
Problem: Redraw flags are not named specifically. Solution: Prefix "UPD_" to the flags, for UPDate_screen().
2022-08-13patch 9.0.0198: ml_get error when switching buffer in Visual modev9.0.0198Bram Moolenaar
Problem: ml_get error when switching buffer in Visual mode. Solution: End Visual mode when switching buffer. (closes #10902)