mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
fix Subversion prompt (#7278)
* fix Subversion prompt - after switching to "string match", some SVN status symbols need proper escaping - the __fish_svn_prompt_flag_names list was missing "versioned_obstructed" and was therefore not in line with the symbols from __fish_svn_prompt_chars - when checking for individual SVN status symbols, use "string match -e" to handle the case where multiple different symbols appear in one status column - use "sort -u" before merging all symbols from a column into one line Fixes #6715 * use regex for SVN status matching Using regex matching will prevent different match behaviour depending on qmark-noglob feature. Also, counting the resulting matches is unnecessary. * use list instead of string for SVN status Make $column_status a list be not removing newlines from SVN status output. This makes checking for the individual status types within a column easier because it doesn't require regex matching. * added quotes for string length test (-n)
This commit is contained in:
parent
0304135d2b
commit
81d87d1c7f
1 changed files with 11 additions and 12 deletions
|
@ -67,18 +67,18 @@ set -g __fish_svn_prompt_char_token_broken_color --bold magenta
|
|||
|
||||
# ==============================
|
||||
|
||||
function __fish_svn_prompt_parse_status --argument flag_status_string --description "helper function that does pretty formatting on svn status"
|
||||
function __fish_svn_prompt_parse_status --description "helper function that does pretty formatting on svn status"
|
||||
# SVN status symbols
|
||||
# Do not change these! These are the expected characters that are output from `svn status`, they are taken from `svn help status`
|
||||
set -l __fish_svn_prompt_chars A C D I M R X \? ! ~ L + S K O T B
|
||||
set -l __fish_svn_prompt_chars A C D I M R X '?' ! '~' L + S K O T B
|
||||
# this sets up an array of all the types of status codes that could be returned.
|
||||
set -l __fish_svn_prompt_flag_names added conflicted deleted ignored modified replaced unversioned_external unversioned missing locked scheduled switched token_present token_other token_stolen token_broken
|
||||
set -l __fish_svn_prompt_flag_names added conflicted deleted ignored modified replaced unversioned_external unversioned missing versioned_obstructed locked scheduled switched token_present token_other token_stolen token_broken
|
||||
# iterate over the different status types
|
||||
for flag_type in $__fish_svn_prompt_flag_names
|
||||
# resolve the name of the variable for the character representing the current status type
|
||||
set -l flag_index (contains -i $flag_type $__fish_svn_prompt_flag_names)
|
||||
# check to see if the status string for this column contains the character representing the current status type
|
||||
if test (count (string match $__fish_svn_prompt_chars[$flag_index] -- $flag_status_string)) -eq 1
|
||||
# check to see if the status list for this column contains the character representing the current status type
|
||||
if contains -- $__fish_svn_prompt_chars[$flag_index] $argv
|
||||
# if it does, then get the names of the variables for the display character and colour to format it with
|
||||
set -l flag_var_display __fish_svn_prompt_char_{$flag_type}_display
|
||||
set -l flag_var_color __fish_svn_prompt_char_{$flag_type}_color
|
||||
|
@ -116,16 +116,15 @@ function fish_svn_prompt --description "Prompt function for svn"
|
|||
# get the output for a particular column
|
||||
# 1. echo the whole status flag text
|
||||
# 2. cut out the current column of characters
|
||||
# 3. remove spaces and newline characters
|
||||
set -l column_status (printf '%s\n' $svn_status_lines | cut -c $col | tr -d ' \n')
|
||||
# 3. remove duplicates
|
||||
# 4. remove spaces
|
||||
set -l column_status (printf '%s\n' $svn_status_lines | cut -c $col | sort -u | tr -d ' ')
|
||||
|
||||
# check that the character count is not zero (this would indicate that there are status flags in this column)
|
||||
if [ (count $column_status) -ne 0 ]
|
||||
# check that the column status list does not only contain an empty element (if it does, this column is empty)
|
||||
if [ (count $column_status) -gt 1 -o -n "$column_status[1]" ]
|
||||
|
||||
# we only want to display unique status flags (eg: if there are 5 modified files, the prompt should only show the modified status once)
|
||||
set -l column_unique_status (echo $column_status | sort -u)
|
||||
# parse the status flags for this column and create the formatting by calling out to the helper function
|
||||
set -l svn_status_flags (__fish_svn_prompt_parse_status $column_unique_status)
|
||||
set -l svn_status_flags (__fish_svn_prompt_parse_status $column_status)
|
||||
|
||||
# the default separator is empty
|
||||
set -l prompt_separator ""
|
||||
|
|
Loading…
Reference in a new issue