From f802698aaf21305c965742926ff468d23b2baf41 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 31 Jan 2021 14:16:39 +0900 Subject: [PATCH 1/3] Force slash path internally to fix behavior on Windows --- autoload/fern_git_status.vim | 3 ++- autoload/fern_git_status/process.vim | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/autoload/fern_git_status.vim b/autoload/fern_git_status.vim index b2ca89c..b62d0be 100644 --- a/autoload/fern_git_status.vim +++ b/autoload/fern_git_status.vim @@ -55,7 +55,8 @@ function! s:on_redraw(helper) abort endfunction function! s:update_node(status_map, node) abort - let status = get(a:status_map, a:node._path, '') + let path = fern#internal#filepath#to_slash(a:node._path) + let status = get(a:status_map, path, '') let a:node.badge = status ==# '' ? '' : printf(' [%s]', status) return a:node endfunction diff --git a/autoload/fern_git_status/process.vim b/autoload/fern_git_status/process.vim index 9d4332d..cff92d4 100644 --- a/autoload/fern_git_status/process.vim +++ b/autoload/fern_git_status/process.vim @@ -12,6 +12,7 @@ function! fern_git_status#process#show_toplevel(root, token) abort \}) \.catch({e -> s:Promise.reject(s:normalize_error(e)) }) \.then({v -> join(v.stdout, '') }) + \.then({v -> s:normalize_path(v) }) \.finally({ -> Profile() }) endfunction @@ -61,5 +62,21 @@ function! s:parse_status(record) abort let status = a:record[:1] let relpath = split(a:record[3:], ' -> ')[-1] let relpath = relpath[-1:] ==# '/' ? relpath[:-2] : relpath + let relpath = s:normalize_path(relpath) return [relpath, status] endfunction + +" NOTE: +" Git for Windows return slash separated path but the path is +" not compatible with fern's slash separated path so normalization +" is required +if has("win32") + function! s:normalize_path(path) abort + let filepath = fern#internal#filepath#from_slash(a:path) + return fern#internal#filepath#to_slash(filepath) + endfunction +else + function! s:normalize_path(path) abort + return a:path + endfunction +endif From 889552c8cf075245f2c25ce75a517894fa9964b5 Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 31 Jan 2021 14:21:14 +0900 Subject: [PATCH 2/3] Fix lint --- autoload/fern_git_status/process.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/fern_git_status/process.vim b/autoload/fern_git_status/process.vim index cff92d4..a8e36dd 100644 --- a/autoload/fern_git_status/process.vim +++ b/autoload/fern_git_status/process.vim @@ -70,7 +70,7 @@ endfunction " Git for Windows return slash separated path but the path is " not compatible with fern's slash separated path so normalization " is required -if has("win32") +if has('win32') function! s:normalize_path(path) abort let filepath = fern#internal#filepath#from_slash(a:path) return fern#internal#filepath#to_slash(filepath) From d4703286e476491cd0569ee3eb70a8aaba01bfac Mon Sep 17 00:00:00 2001 From: Alisue Date: Sun, 31 Jan 2021 16:15:17 +0900 Subject: [PATCH 3/3] Add tap to debug status_map --- autoload/fern_git_status.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/fern_git_status.vim b/autoload/fern_git_status.vim index b62d0be..a7b6512 100644 --- a/autoload/fern_git_status.vim +++ b/autoload/fern_git_status.vim @@ -49,6 +49,7 @@ function! s:on_redraw(helper) abort \ 'stained_patterns': g:fern_git_status#stained_patterns, \} call fern_git_status#investigator#investigate(a:helper, options) + \.then({ m -> fern#logger#tap(m) }) \.then({ m -> map(a:helper.fern.visible_nodes, { -> s:update_node(m, v:val) }) }) \.then({ -> s:redraw(a:helper) }) \.catch({ e -> s:handle_error(e) })