File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ local function generate_center(config)
118118 buffer = config .bufnr ,
119119 callback = function ()
120120 local buf = api .nvim_win_get_buf (0 )
121- if vim .api .nvim_buf_get_option ( buf , ' filetype' ) ~= ' dashboard' then
121+ if vim .api .nvim_get_option_value ( ' filetype' , { buf = buf } ) ~= ' dashboard' then
122122 return
123123 end
124124
@@ -132,11 +132,14 @@ local function generate_center(config)
132132 end
133133 before = curline
134134
135- -- FIX: #422: In Lua the length of a string is the numbers of bytes not
135+ -- FIX: #422: In Lua the length of a string is the number of bytes not
136136 -- the number of characters.
137137 local curline_str = api .nvim_buf_get_lines (config .bufnr , curline - 1 , curline , false )[1 ]
138- local delta = col_width - api .nvim_strwidth (curline_str :sub (1 , col + 1 ))
139- api .nvim_win_set_cursor (config .winid , { curline , col + delta })
138+ local offset = col_width - api .nvim_strwidth (curline_str :sub (1 , col + 1 ))
139+ if offset < 0 then
140+ offset = 0
141+ end
142+ api .nvim_win_set_cursor (config .winid , { curline , col + offset })
140143 end ,
141144 })
142145 end , 0 )
You can’t perform that action at this time.
0 commit comments