Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1065 from dritter/protect_locale
Browse files Browse the repository at this point in the history
Protect locale
  • Loading branch information
dritter committed Nov 17, 2018
2 parents 67fd577 + 4ebb9f9 commit 724781e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions functions/icons.zsh
Expand Up @@ -13,6 +13,7 @@

# Initialize the icon list according to the user's `POWERLEVEL9K_MODE`.
typeset -gAH icons
() { # add scope to protect the users locale and not overwrite LC_CTYPE!
case $POWERLEVEL9K_MODE in
'flat'|'awesome-patched')
# Awesome-Patched Font required! See:
Expand Down Expand Up @@ -528,6 +529,7 @@ esac
if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then
icons[VCS_BRANCH_ICON]=''
fi
}

# Safety function for printing icons
# Prints the named icon, or if that icon is undefined, the string name.
Expand Down
30 changes: 18 additions & 12 deletions test/functions/icons.spec
Expand Up @@ -17,52 +17,58 @@ function tearDown() {
LC_CTYPE="${_OLD_LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInDefaultMode() {
function testLcCtypeIsNotOverwrittenInDefaultMode() {
local POWERLEVEL9K_MODE="default"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInAwesomePatchedMode() {
function testLcCtypeIsNotOverwrittenInAwesomePatchedMode() {
local POWERLEVEL9K_MODE="awesome-patched"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInAwesomeFontconfigMode() {
function testLcCtypeIsNotOverwrittenInAwesomeFontconfigMode() {
local POWERLEVEL9K_MODE="awesome-fontconfig"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInNerdfontFontconfigMode() {
function testLcCtypeIsNotOverwrittenInNerdfontFontconfigMode() {
local POWERLEVEL9K_MODE="nerdfont-fontconfig"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInFlatMode() {
function testLcCtypeIsNotOverwrittenInFlatMode() {
local POWERLEVEL9K_MODE="flat"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

function testLcCtypeIsSetCorrectlyInCompatibleMode() {
function testLcCtypeIsNotOverwrittenInCompatibleMode() {
local POWERLEVEL9K_MODE="compatible"
local LC_CTYPE="my-locale"
# Load Powerlevel9k
source functions/icons.zsh

assertEquals 'en_US.UTF-8' "${LC_CTYPE}"
assertEquals 'my-locale' "${LC_CTYPE}"
}

# Go through all icons defined in default mode, and
Expand Down

0 comments on commit 724781e

Please sign in to comment.