Skip to content

Commit 8b64f3b

Browse files
committed
* #RI-6581 - Empty delimiter can be applied
* #RI-6582 - The same delimiter can be applied multiple times
1 parent fe29f4f commit 8b64f3b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/webviews/src/modules/settings/Settings.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { VscCheck } from 'react-icons/vsc'
77

88
import { Separator } from 'uiSrc/ui'
99
import { ConsentsPrivacy, MultiSelect, MultiSelectOption } from 'uiSrc/components'
10-
import { VscodeMessageAction } from 'uiSrc/constants'
10+
import { DEFAULT_DELIMITER, VscodeMessageAction } from 'uiSrc/constants'
1111
import { vscodeApi } from 'uiSrc/services'
1212
import { useAppInfoStore } from 'uiSrc/store/hooks/use-app-info-store/useAppInfoStore'
1313
import { TelemetryEvent, arrayToMultiSelect, multiSelectToArray, sendEventTelemetry } from 'uiSrc/utils'
@@ -27,7 +27,9 @@ export const Settings = () => {
2727
const [delimiters, setDelimiters] = useState<readonly MultiSelectOption[]>(delimitersProp)
2828

2929
const handleApplyClick = () => {
30-
const delims = multiSelectToArray(delimiters)
30+
const delimitersInit = multiSelectToArray(delimiters)
31+
const delims = delimitersInit.length ? delimitersInit : [DEFAULT_DELIMITER]
32+
3133
if (isEqual(delimitersProp, delimiters)) {
3234
return
3335
}
@@ -40,6 +42,7 @@ export const Settings = () => {
4042
},
4143
})
4244

45+
setDelimiters(arrayToMultiSelect(delims))
4346
setDelimitersAction(delims)
4447

4548
vscodeApi.postMessage({ action: VscodeMessageAction.UpdateSettingsDelimiter, data: delims })
@@ -57,6 +60,10 @@ export const Settings = () => {
5760
switch (event.key) {
5861
case 'Enter':
5962
case ' ':
63+
if (delimiters.find(({ value }) => value === inputValue)) {
64+
return
65+
}
66+
6067
setOption()
6168
event.preventDefault()
6269
}

0 commit comments

Comments
 (0)