Skip to content

Commit d49035c

Browse files
author
yaroslav8765
committed
chore: improved code readability
1 parent a6f3883 commit d49035c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

custom/completionInput.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
:class="[
3434
'text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800',
3535
'font-medium rounded-lg text-xs flex items-center justify-center py-1 px-1 ',
36-
buttonText === 'TAB' ? 'w-16' : 'w-18'
36+
buttonText === approveCompletionValue ? 'w-16' : 'w-18'
3737
]">
3838
<div
3939
class="flex items-center justify-center"
40-
v-if="buttonText === 'TAB'"
40+
v-if="buttonText === approveCompletionValue"
4141
>
4242
<IconArrowRightThin class="mt-0.5 w-5 h-5 text-white"/>
4343
<span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
@@ -46,7 +46,7 @@
4646
</div>
4747
<div
4848
class="flex items-center justify-center"
49-
v-else-if="buttonText === 'CTRL + ->'"
49+
v-else-if="buttonText === approveNextWorldValue"
5050
>
5151
<IconArrowRightThin class="mt-0.5 w-5 h-5 text-white" />
5252
<span class="ml-1 px-1 h-4 flex items-center justify-center rounded border bg-white text-black text-[10px] font-mono shadow-inner shadow-sm border-gray-300 dark:bg-gray-700 dark:text-white dark:border-gray-500">
@@ -85,24 +85,24 @@ const props = defineProps<{
8585
const emit = defineEmits([
8686
'update:value',
8787
]);
88-
88+
const approveCompletionValue:string='TAB';
89+
const approveNextWorldValue:string='CTRL + ->'
8990
const isLoading = ref<boolean>(false);
9091
const isUntouched = ref<boolean>(true);
9192
const isFocused = ref<boolean>(false);
9293
const currentValue: Ref<string> = ref('');
9394
const suggestionInputRef = ref<InstanceType<typeof SuggestionInput> | null>(null);
94-
const buttonText = ref<string>('TAB');
95+
const buttonText = ref<string>(approveCompletionValue);
9596
9697
const tooltipText = computed(() =>
97-
buttonText.value === 'TAB' ? 'Approve completion' : 'Approve next word'
98+
buttonText.value === approveCompletionValue ? 'Approve completion' : 'Approve next word'
9899
);
99100
100101
function handleCompletionApproved(type: 'all' | 'word') {
101-
console.log('🔥 Completion approved with type:', type);
102-
if(buttonText.value === 'TAB' && type === 'all') {
103-
buttonText.value = 'CTRL + ->';
104-
} else if (buttonText.value === 'CTRL + ->' && type === 'word') {
105-
buttonText.value = 'TAB';
102+
if(buttonText.value === approveCompletionValue && type === 'all') {
103+
buttonText.value = approveNextWorldValue;
104+
} else if (buttonText.value === approveNextWorldValue && type === 'word') {
105+
buttonText.value = approveCompletionValue;
106106
}
107107
}
108108
@@ -151,13 +151,13 @@ async function complete(textBeforeCursor: string) {
151151
152152
const approveCompletion = async () => {
153153
if (suggestionInputRef.value) {
154-
if( buttonText.value === 'TAB') {
154+
if( buttonText.value === approveCompletionValue) {
155155
await suggestionInputRef.value.approveCompletion('all');
156156
} else {
157157
await suggestionInputRef.value.approveCompletion('word');
158158
}
159159
}
160-
buttonText.value === 'TAB' ? buttonText.value = 'CTRL + ->' : buttonText.value = 'TAB';
160+
buttonText.value === approveCompletionValue ? buttonText.value = approveNextWorldValue : buttonText.value = approveCompletionValue;
161161
}
162162
163163
function handleFocus() {

0 commit comments

Comments
 (0)