mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
vim-patch:8.1.1736: viminfo support is spread out
Problem: Viminfo support is spread out. Solution: Move more viminfo code to viminfo.c. (Yegappan Lakshmanan, closes vim/vim#4717) Reorder code to make most functions static.c3328169d5
735aa4c4c8
was the partial port for the typedefs. This patch completes the viminfo->shada port. - get_shada_parameter() - find_shada_parameter() Other patches below are N/A. vim-patch:8.1.1728: wrong place for command line history viminfo support Problem: Wrong place for command line history viminfo support. Solution: Move it to viminfo.c.5f32ece459
vim-patch:8.1.1730: wrong place for mark viminfo support Problem: Wrong place for mark viminfo support. Solution: Move it to viminfo.c. (Yegappan Lakshmanan, closes vim/vim#4716)1e78e69680
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -2049,20 +2049,6 @@ static char *readfile_charconvert(char *fname, char *fenc, int *fdp)
|
|||||||
return tmpname;
|
return tmpname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read marks for the current buffer from the ShaDa file, when we support
|
|
||||||
/// buffer marks and the buffer has a name.
|
|
||||||
static void check_marks_read(void)
|
|
||||||
{
|
|
||||||
if (!curbuf->b_marks_read && get_shada_parameter('\'') > 0
|
|
||||||
&& curbuf->b_ffname != NULL) {
|
|
||||||
shada_read_marks();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always set b_marks_read; needed when 'shada' is changed to include
|
|
||||||
// the ' parameter after opening a buffer.
|
|
||||||
curbuf->b_marks_read = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set the name of the current buffer. Use when the buffer doesn't have a
|
/// Set the name of the current buffer. Use when the buffer doesn't have a
|
||||||
/// name and a ":r" or ":w" command with a file name is used.
|
/// name and a ":r" or ":w" command with a file name is used.
|
||||||
int set_rw_fname(char *fname, char *sfname)
|
int set_rw_fname(char *fname, char *sfname)
|
||||||
|
@@ -1537,40 +1537,6 @@ void set_options_bin(int oldval, int newval, int opt_flags)
|
|||||||
didset_options_sctx(opt_flags, p_bin_dep_opts);
|
didset_options_sctx(opt_flags, p_bin_dep_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find the parameter represented by the given character (eg ', :, ", or /),
|
|
||||||
/// and return its associated value in the 'shada' string.
|
|
||||||
/// Only works for number parameters, not for 'r' or 'n'.
|
|
||||||
/// If the parameter is not specified in the string or there is no following
|
|
||||||
/// number, return -1.
|
|
||||||
int get_shada_parameter(int type)
|
|
||||||
{
|
|
||||||
char *p = find_shada_parameter(type);
|
|
||||||
if (p != NULL && ascii_isdigit(*p)) {
|
|
||||||
return atoi(p);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Find the parameter represented by the given character (eg ''', ':', '"', or
|
|
||||||
/// '/') in the 'shada' option and return a pointer to the string after it.
|
|
||||||
/// Return NULL if the parameter is not specified in the string.
|
|
||||||
char *find_shada_parameter(int type)
|
|
||||||
{
|
|
||||||
for (char *p = p_shada; *p; p++) {
|
|
||||||
if (*p == type) {
|
|
||||||
return p + 1;
|
|
||||||
}
|
|
||||||
if (*p == 'n') { // 'n' is always the last one
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
p = vim_strchr(p, ','); // skip until next ','
|
|
||||||
if (p == NULL) { // hit the end without finding parameter
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Expand environment variables for some string options.
|
/// Expand environment variables for some string options.
|
||||||
/// These string options cannot be indirect!
|
/// These string options cannot be indirect!
|
||||||
/// If "val" is NULL expand the current value of the option.
|
/// If "val" is NULL expand the current value of the option.
|
||||||
|
@@ -43,6 +43,7 @@
|
|||||||
#include "nvim/pos_defs.h"
|
#include "nvim/pos_defs.h"
|
||||||
#include "nvim/regexp.h"
|
#include "nvim/regexp.h"
|
||||||
#include "nvim/regexp_defs.h"
|
#include "nvim/regexp_defs.h"
|
||||||
|
#include "nvim/shada.h"
|
||||||
#include "nvim/spell.h"
|
#include "nvim/spell.h"
|
||||||
#include "nvim/spellfile.h"
|
#include "nvim/spellfile.h"
|
||||||
#include "nvim/spellsuggest.h"
|
#include "nvim/spellsuggest.h"
|
||||||
|
@@ -3772,3 +3772,51 @@ void shada_read_string(String string, const int flags)
|
|||||||
shada_read(&sd_reader, flags);
|
shada_read(&sd_reader, flags);
|
||||||
close_file(&sd_reader);
|
close_file(&sd_reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Find the parameter represented by the given character (eg ', :, ", or /),
|
||||||
|
/// and return its associated value in the 'shada' string.
|
||||||
|
/// Only works for number parameters, not for 'r' or 'n'.
|
||||||
|
/// If the parameter is not specified in the string or there is no following
|
||||||
|
/// number, return -1.
|
||||||
|
int get_shada_parameter(int type)
|
||||||
|
{
|
||||||
|
char *p = find_shada_parameter(type);
|
||||||
|
if (p != NULL && ascii_isdigit(*p)) {
|
||||||
|
return atoi(p);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Find the parameter represented by the given character (eg ''', ':', '"', or
|
||||||
|
/// '/') in the 'shada' option and return a pointer to the string after it.
|
||||||
|
/// Return NULL if the parameter is not specified in the string.
|
||||||
|
char *find_shada_parameter(int type)
|
||||||
|
{
|
||||||
|
for (char *p = p_shada; *p; p++) {
|
||||||
|
if (*p == type) {
|
||||||
|
return p + 1;
|
||||||
|
}
|
||||||
|
if (*p == 'n') { // 'n' is always the last one
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p = vim_strchr(p, ','); // skip until next ','
|
||||||
|
if (p == NULL) { // hit the end without finding parameter
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Read marks for the current buffer from the ShaDa file, when we support
|
||||||
|
/// buffer marks and the buffer has a name.
|
||||||
|
void check_marks_read(void)
|
||||||
|
{
|
||||||
|
if (!curbuf->b_marks_read && get_shada_parameter('\'') > 0
|
||||||
|
&& curbuf->b_ffname != NULL) {
|
||||||
|
shada_read_marks();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always set b_marks_read; needed when 'shada' is changed to include
|
||||||
|
// the ' parameter after opening a buffer.
|
||||||
|
curbuf->b_marks_read = true;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user