Skip to content

Commit 2cc2583

Browse files
committed
Merge the first three commits of PR #669
* commit 'b1f36d9c5f45b879fbd2f64195167a60d9f3cb9e': 'main': Add a comment. 'main': Fix the $CDPATH from the previous commit. 'main': Add a test for a $CDPATH bug.
2 parents e15781c + b1f36d9 commit 2cc2583

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

highlighters/main/main-highlighter.zsh

+7-4
Original file line numberDiff line numberDiff line change
@@ -1103,10 +1103,13 @@ _zsh_highlight_main_highlighter_check_path()
11031103
[[ -e $expanded_path ]] && return 0
11041104

11051105
# Search the path in CDPATH
1106-
local cdpath_dir
1107-
for cdpath_dir in $cdpath ; do
1108-
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
1109-
done
1106+
if [[ $expanded_path != /* ]]; then
1107+
local cdpath_dir
1108+
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
1109+
for cdpath_dir in $cdpath ; do
1110+
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
1111+
done
1112+
fi
11101113

11111114
# If dirname($1) doesn't exist, neither does $1.
11121115
[[ ! -d ${expanded_path:h} ]] && return 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env zsh
2+
# -------------------------------------------------------------------------------------------------
3+
# Copyright (c) 2020 zsh-syntax-highlighting contributors
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without modification, are permitted
7+
# provided that the following conditions are met:
8+
#
9+
# * Redistributions of source code must retain the above copyright notice, this list of conditions
10+
# and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above copyright notice, this list of
12+
# conditions and the following disclaimer in the documentation and/or other materials provided
13+
# with the distribution.
14+
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
15+
# may be used to endorse or promote products derived from this software without specific prior
16+
# written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20+
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
# -------------------------------------------------------------------------------------------------
27+
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
28+
# vim: ft=zsh sw=2 ts=2 et
29+
# -------------------------------------------------------------------------------------------------
30+
31+
cdpath=( $PWD )
32+
mkdir foo foo/bar
33+
34+
BUFFER="/foo"
35+
36+
expected_region_highlight=(
37+
'1 4 unknown-token' # x (/)
38+
)

0 commit comments

Comments
 (0)