Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent fix #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions autoload/promptline/sections.vim
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,22 @@ fun! s:make_function( function_name, preset, section_names, is_left )
\'function ' . a:function_name . ' {',
\ section_local_variables]

let b:is_warn = 0
for section_name in a:section_names
let [ slice_prefix, slice_empty_prefix, slice_middle, slice_suffix ] = s:get_slice_modifiers(section_name, a:is_left)
let func_body += [
\'',
\' # section "' . section_name . '" header',
\' slice_prefix=' . slice_prefix . ' slice_suffix=' . slice_suffix . ' slice_joiner=' . slice_middle . ' slice_empty_prefix=' . slice_empty_prefix]
if section_name == "warn"
let b:is_warn = 1
let func_body += [
\'',
\' # section "' . section_name . '" header',
\' if [ ! -e $(__promptline_last_exit_code) ]; then',
\' slice_prefix=' . slice_prefix . ' slice_suffix=' . slice_suffix . ' slice_joiner=' . slice_middle . ' slice_empty_prefix=' . slice_empty_prefix ]
else
let func_body += [
\'',
\' # section "' . section_name . '" header',
\' slice_prefix=' . slice_prefix . ' slice_suffix=' . slice_suffix . ' slice_joiner=' . slice_middle . ' slice_empty_prefix=' . slice_empty_prefix ]
endif

" only left sections should check $is_prompt_empty
if a:is_left
Expand All @@ -86,7 +96,17 @@ fun! s:make_function( function_name, preset, section_names, is_left )
\ : '"' . slice . '"'
let slice_content = ' ' . wrapper_slice.function_name . ' ' . slice_value . ' "$slice_prefix" "$slice_suffix" && { slice_prefix="$slice_joiner";' . slice_command_trailer . ' }'

let func_body += [ slice_content ]
if b:is_warn == 1
let b:is_warn = 0
let func_body += [
\ ' ' . slice_content,
\ ' else',
\ ' slice_prefix="${reset}"',
\ ' ' . wrapper_slice.function_name . ' "${reset} "',
\ ' fi' ]
else
let func_body += [ slice_content ]
endif
unlet slice
endfor
endfor
Expand Down