@@ -112,56 +112,34 @@ __vsc_escape_value() {
112112 fi
113113
114114 # Process text byte by byte, not by codepoint.
115- builtin local LC_ALL=C str=" ${1} " i byte token out=' '
115+ local -r LC_ALL=C
116+ local -r str=" ${1} "
117+ local -ir len=" ${# str} "
118+
119+ local -i i
120+ local -i val
121+ local byte
122+ local token
123+ local out=' '
116124
117125 for (( i= 0 ; i < "${# str} "; ++ i )) ; do
118- byte=" ${str: $i : 1} "
119126 # Escape backslashes, semi-colons specially, then special ASCII chars below space (0x20).
120- # This is done in an unwrapped loop instead of using printf as the latter is very slow.
121- if [ " $byte " = " \\ " ]; then
127+ byte=" ${str: $i : 1} "
128+ builtin printf -v val ' %d' " '$byte "
129+ if (( val < 31 )) ; then
130+ builtin printf -v token ' \\x%02x' " '$byte "
131+ elif (( val == 92 )) ; then
122132 token=" \\\\ "
123- elif [ " $byte " = " ; " ] ; then
133+ elif (( val == 59 )) ; then
124134 token=" \\ x3b"
125- elif [ " $byte " = $' \x00 ' ]; then token=" \\ x00"
126- elif [ " $byte " = $' \x01 ' ]; then token=" \\ x01"
127- elif [ " $byte " = $' \x02 ' ]; then token=" \\ x02"
128- elif [ " $byte " = $' \x03 ' ]; then token=" \\ x03"
129- elif [ " $byte " = $' \x04 ' ]; then token=" \\ x04"
130- elif [ " $byte " = $' \x05 ' ]; then token=" \\ x05"
131- elif [ " $byte " = $' \x06 ' ]; then token=" \\ x06"
132- elif [ " $byte " = $' \x07 ' ]; then token=" \\ x07"
133- elif [ " $byte " = $' \x08 ' ]; then token=" \\ x08"
134- elif [ " $byte " = $' \x09 ' ]; then token=" \\ x09"
135- elif [ " $byte " = $' \x0a ' ]; then token=" \\ x0a"
136- elif [ " $byte " = $' \x0b ' ]; then token=" \\ x0b"
137- elif [ " $byte " = $' \x0c ' ]; then token=" \\ x0c"
138- elif [ " $byte " = $' \x0d ' ]; then token=" \\ x0d"
139- elif [ " $byte " = $' \x0e ' ]; then token=" \\ x0e"
140- elif [ " $byte " = $' \x0f ' ]; then token=" \\ x0f"
141- elif [ " $byte " = $' \x10 ' ]; then token=" \\ x10"
142- elif [ " $byte " = $' \x11 ' ]; then token=" \\ x11"
143- elif [ " $byte " = $' \x12 ' ]; then token=" \\ x12"
144- elif [ " $byte " = $' \x13 ' ]; then token=" \\ x13"
145- elif [ " $byte " = $' \x14 ' ]; then token=" \\ x14"
146- elif [ " $byte " = $' \x15 ' ]; then token=" \\ x15"
147- elif [ " $byte " = $' \x16 ' ]; then token=" \\ x16"
148- elif [ " $byte " = $' \x17 ' ]; then token=" \\ x17"
149- elif [ " $byte " = $' \x18 ' ]; then token=" \\ x18"
150- elif [ " $byte " = $' \x19 ' ]; then token=" \\ x19"
151- elif [ " $byte " = $' \x1a ' ]; then token=" \\ x1a"
152- elif [ " $byte " = $' \x1b ' ]; then token=" \\ x1b"
153- elif [ " $byte " = $' \x1c ' ]; then token=" \\ x1c"
154- elif [ " $byte " = $' \x1d ' ]; then token=" \\ x1d"
155- elif [ " $byte " = $' \x1e ' ]; then token=" \\ x1e"
156- elif [ " $byte " = $' \x1f ' ]; then token=" \\ x1f"
157135 else
158136 token=" $byte "
159137 fi
160138
161139 out+=" $token "
162140 done
163141
164- builtin printf ' %s\n' " ${ out} "
142+ builtin printf ' %s\n' " $out "
165143}
166144
167145# Send the IsWindows property if the environment looks like Windows
@@ -196,11 +174,6 @@ unset VSCODE_NONCE
196174builtin printf " \e]633;P;ContinuationPrompt=$( echo " $PS2 " | sed ' s/\x1b/\\\\x1b/g' ) \a"
197175
198176__vsc_report_prompt () {
199- # HACK: Git bash is too slow at reporting the prompt, so skip for now
200- if [ " $__vsc_is_windows " = " 1" ]; then
201- return
202- fi
203-
204177 # Expand the original PS1 similarly to how bash would normally
205178 # See https://stackoverflow.com/a/37137981 for technique
206179 if (( BASH_VERSINFO[0 ] >= 5 || (BASH_VERSINFO[0 ] == 4 && BASH_VERSINFO[1 ] >= 4 )) ); then
0 commit comments