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