2023-07-20 14:25:13 -04:00
|
|
|
# shellcheck disable=SC1091,2148
|
|
|
|
|
2019-04-14 16:53:09 -04:00
|
|
|
DEFAULT_TRUE="'default': true"
|
|
|
|
DEFAULT_FALSE="'default': false"
|
2021-10-19 14:55:44 -04:00
|
|
|
DEFAULT_ON="'default': TelemetryConfiguration.ON"
|
|
|
|
DEFAULT_OFF="'default': TelemetryConfiguration.OFF"
|
2019-04-14 16:53:09 -04:00
|
|
|
TELEMETRY_CRASH_REPORTER="'telemetry.enableCrashReporter':"
|
2021-10-19 14:55:44 -04:00
|
|
|
TELEMETRY_CONFIGURATION=" TelemetryConfiguration.ON"
|
2022-09-18 16:24:50 -04:00
|
|
|
NLS=workbench.settings.enableNaturalLanguageSearch
|
2019-04-14 16:53:09 -04:00
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
# include common functions
|
2021-07-21 16:49:00 -04:00
|
|
|
. ../utils.sh
|
2019-04-14 16:53:09 -04:00
|
|
|
|
|
|
|
update_setting () {
|
2023-07-23 12:35:27 -04:00
|
|
|
local FILENAME SETTING LINE_NUM IN_SETTING FOUND DEFAULT_TRUE_TO_FALSE
|
|
|
|
|
|
|
|
FILENAME="${2}"
|
2019-04-14 16:53:09 -04:00
|
|
|
# check that the file exists
|
2023-07-23 12:35:27 -04:00
|
|
|
if [[ ! -f "${FILENAME}" ]]; then
|
2019-04-14 16:53:09 -04:00
|
|
|
echo "File to update setting in does not exist ${FILENAME}"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# go through lines of file, looking for block that contains setting
|
2023-07-23 12:35:27 -04:00
|
|
|
SETTING="${1}"
|
|
|
|
LINE_NUM=0
|
2019-04-14 16:53:09 -04:00
|
|
|
while read -r line; do
|
2023-07-23 12:35:27 -04:00
|
|
|
LINE_NUM=$(( LINE_NUM + 1 ))
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${line}" == *"${SETTING}"* ]]; then
|
2023-07-23 12:35:27 -04:00
|
|
|
IN_SETTING=1
|
2019-04-14 16:53:09 -04:00
|
|
|
fi
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ ("${line}" == *"${DEFAULT_TRUE}"* || "${line}" == *"${DEFAULT_ON}"*) && "${IN_SETTING}" == "1" ]]; then
|
2023-07-23 12:35:27 -04:00
|
|
|
FOUND=1
|
2019-04-14 16:53:09 -04:00
|
|
|
break
|
|
|
|
fi
|
2022-06-05 15:30:23 -04:00
|
|
|
done < "${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${FOUND}" != "1" ]]; then
|
|
|
|
echo "${DEFAULT_TRUE} not found for setting ${SETTING} in file ${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# construct line-aware replacement string
|
2022-06-05 15:30:23 -04:00
|
|
|
if [[ "${line}" == *"${DEFAULT_TRUE}"* ]]; then
|
2023-07-23 12:35:27 -04:00
|
|
|
DEFAULT_TRUE_TO_FALSE="${LINE_NUM}s/${DEFAULT_TRUE}/${DEFAULT_FALSE}/"
|
2022-04-07 14:30:38 -04:00
|
|
|
else
|
2023-07-23 12:35:27 -04:00
|
|
|
DEFAULT_TRUE_TO_FALSE="${LINE_NUM}s/${DEFAULT_ON}/${DEFAULT_OFF}/"
|
2021-10-19 14:55:44 -04:00
|
|
|
fi
|
2022-04-07 14:30:38 -04:00
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
replace "${DEFAULT_TRUE_TO_FALSE}" "${FILENAME}"
|
2019-04-14 16:53:09 -04:00
|
|
|
}
|
|
|
|
|
2022-06-05 15:30:23 -04:00
|
|
|
update_setting "${TELEMETRY_CRASH_REPORTER}" src/vs/workbench/electron-sandbox/desktop.contribution.ts
|
|
|
|
update_setting "${TELEMETRY_CONFIGURATION}" src/vs/platform/telemetry/common/telemetryService.ts
|
2022-09-18 16:24:50 -04:00
|
|
|
update_setting "${NLS}" src/vs/workbench/contrib/preferences/common/preferencesContribution.ts
|