Skip to content

Commit bc8f00d

Browse files
committed
treat languages of enabled input methods as current
1 parent 0633d07 commit bc8f00d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/InputMethodConfig.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const props = defineProps<{
3131
onClose: () => void
3232
}>()
3333
34+
const enabledIMs = computed(() => props.inputMethods.map(({ name }) => name))
35+
3436
const selectedInputMethod = ref(props.inputMethod)
3537
const uri = computed(() => `fcitx://config/inputmethod/${selectedInputMethod.value}`)
3638
@@ -81,18 +83,21 @@ let map: { [key: string]: {
8183
name: string
8284
displayName: string
8385
}[] } = {}
86+
let languageOfIM: { [key: string]: string } = {}
8487
8588
watchEffect(() => {
8689
if (!adding.value) {
8790
return
8891
}
8992
map = {}
93+
languageOfIM = {}
9094
for (const im of window.fcitx.getAllInputMethods()) {
9195
const code = im.languageCode.replace('_', '-');
9296
(map[code] = map[code] || []).push({
9397
name: im.name,
9498
displayName: im.displayName,
9599
})
100+
languageOfIM[im.name] = code
96101
}
97102
languageOptions.value = []
98103
const sortedLanguageCodes = Object.keys(map).sort((a: string, b: string) => {
@@ -124,8 +129,7 @@ const inputMethodsForLanguage = computed(() => {
124129
if (selectedLanguage.value === null) {
125130
return []
126131
}
127-
const enabledIMs = props.inputMethods.map(({ name }) => name)
128-
return map[selectedLanguage.value].filter(({ name }) => !enabledIMs.includes(name))
132+
return map[selectedLanguage.value].filter(({ name }) => !enabledIMs.value.includes(name))
129133
})
130134
131135
const imsToAdd = ref<string[]>([])
@@ -141,7 +145,9 @@ const onlyShowCurrentLanguage = ref(false)
141145
const filteredLanguageOptions = computed(() => {
142146
if (onlyShowCurrentLanguage.value) {
143147
const currentLanguage = navigator.language.split('-')[0]
144-
return languageOptions.value.filter(({ key }) => key.split('-')[0] === currentLanguage)
148+
const languages = new Set(enabledIMs.value.map(name => languageOfIM[name]).filter(code => code))
149+
languages.add(currentLanguage)
150+
return languageOptions.value.filter(({ key }) => languages.has(key.split('-')[0]))
145151
}
146152
return languageOptions.value
147153
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy