-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: break state when okuriari convert at EOL
- Loading branch information
Showing
1 changed file
with
8 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
let s:textwidth = {} | ||
let s:virtualedit = {} | ||
|
||
function s:ensure(dict, key, value) | ||
let a:dict[a:key] = get(a:dict, a:key, a:value) | ||
endfunction | ||
|
||
function skkeleton#internal#option#save_and_set() | ||
call s:ensure(s:textwidth, bufnr(), &l:textwidth) | ||
call s:ensure(s:virtualedit, win_getid(), &l:virtualedit) | ||
" 不意に改行が発生してバッファが壊れるため 'textwidth' を無効化 | ||
setlocal textwidth=0 | ||
" 末尾で送りあり変換をした際にバッファが壊れるため、一時的に 'virtualedit' を使う | ||
setlocal virtualedit=all | ||
endfunction | ||
|
||
function skkeleton#internal#option#restore() | ||
let bufnr = bufnr() | ||
let winid = win_getid() | ||
if has_key(s:textwidth, bufnr) | ||
let &l:textwidth = remove(s:textwidth, bufnr) | ||
endif | ||
if has_key(s:virtualedit, winid) | ||
let &l:virtualedit = remove(s:virtualedit, winid) | ||
endif | ||
endfunction |