Skip to content

Commit 8f1ebd2

Browse files
committed
Remove the file path autocompletion hint feature entirely
1 parent f13b73d commit 8f1ebd2

4 files changed

Lines changed: 0 additions & 150 deletions

File tree

‎packages/ui/src/components/editor/panel/PromptField/PromptField.module.scss‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,6 @@
115115
}
116116
}
117117

118-
.input-with-file-match-hint {
119-
&::after {
120-
content: '\\';
121-
display: inline-flex;
122-
align-items: center;
123-
justify-content: center;
124-
color: var(--cwc-text-color);
125-
font-size: 10px;
126-
padding: 0 3px;
127-
margin-left: 2px;
128-
transform: translateY(-1px);
129-
font-weight: 500;
130-
border: 1px solid var(--cwc-border-color);
131-
border-radius: 5px;
132-
pointer-events: none;
133-
opacity: var(--dimmed-opacity);
134-
}
135-
}
136-
137118
.selection-keyword {
138119
background-color: var(--vscode-editor-selectionBackground);
139120
border-radius: 2px;

‎packages/ui/src/components/editor/panel/PromptField/PromptField.tsx‎

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
map_raw_pos_to_display_pos
2020
} from './utils/position-mapping'
2121
import { dictionary } from '@shared/constants/dictionary'
22-
import { get_file_match_hint_data } from './utils/get-file-match-hint-data'
2322

2423
const Tooltip: React.FC<{
2524
message: string
@@ -83,12 +82,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
8382
const [show_submit_tooltip, set_show_submit_tooltip] = useState(false)
8483
const [is_text_selecting, set_is_text_selecting] = useState(false)
8584
const [is_focused, set_is_focused] = useState(false)
86-
const [show_file_match_hint, set_show_file_match_hint] = useState(false)
87-
const file_match_hint_timer_ref = useRef<ReturnType<
88-
typeof setTimeout
89-
> | null>(null)
90-
const has_shown_hint_once_ref = useRef(false)
91-
const last_matching_word_ref = useRef<string | null>(null)
9285

9386
const is_narrow_viewport = use_is_narrow_viewport(268)
9487
const {
@@ -157,48 +150,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
157150
return get_display_text(props.value, props.context_file_paths ?? [])
158151
}, [props.value, props.context_file_paths])
159152

160-
const should_show_hint = useMemo(() => {
161-
const hint_data = get_file_match_hint_data(
162-
display_text,
163-
caret_position,
164-
props.context_file_paths
165-
)
166-
return hint_data ? hint_data.word : false
167-
}, [display_text, caret_position, props.context_file_paths])
168-
169-
useEffect(() => {
170-
if (file_match_hint_timer_ref.current) {
171-
clearTimeout(file_match_hint_timer_ref.current)
172-
file_match_hint_timer_ref.current = null
173-
}
174-
175-
if (should_show_hint) {
176-
const matching_word = should_show_hint as string
177-
const is_same_word = matching_word === last_matching_word_ref.current
178-
if (has_shown_hint_once_ref.current && is_same_word) {
179-
set_show_file_match_hint(true)
180-
} else {
181-
file_match_hint_timer_ref.current = setTimeout(() => {
182-
set_show_file_match_hint(true)
183-
has_shown_hint_once_ref.current = true
184-
last_matching_word_ref.current = matching_word
185-
}, 300)
186-
}
187-
} else {
188-
set_show_file_match_hint(false)
189-
if (last_matching_word_ref.current !== null) {
190-
has_shown_hint_once_ref.current = false
191-
last_matching_word_ref.current = null
192-
}
193-
}
194-
195-
return () => {
196-
if (file_match_hint_timer_ref.current) {
197-
clearTimeout(file_match_hint_timer_ref.current)
198-
}
199-
}
200-
}, [should_show_hint])
201-
202153
const highlighted_html = useMemo(() => {
203154
return get_highlighted_text({
204155
text: props.value,
@@ -375,7 +326,6 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
375326
onFocus={() => set_is_focused(true)}
376327
onBlur={() => set_is_focused(false)}
377328
className={cn(styles.input, {
378-
[styles['input-with-file-match-hint']]: show_file_match_hint,
379329
[styles['input--empty']]: !props.value
380330
})}
381331
data-placeholder={placeholder}

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
map_display_pos_to_raw_pos,
99
map_raw_pos_to_display_pos
1010
} from '../utils/position-mapping'
11-
import { get_file_match_hint_data } from '../utils/get-file-match-hint-data'
1211

1312
type HistoryEntry = {
1413
value: string
@@ -410,39 +409,6 @@ export const use_handlers = (
410409
const caret_position = get_caret_position_from_div(currentTarget)
411410
const char_before_caret = new_display_value.charAt(caret_position - 1)
412411

413-
if (char_before_caret == '\\') {
414-
const display_value_before_backslash = new_display_value.substring(
415-
0,
416-
caret_position - 1
417-
)
418-
const hint_data = get_file_match_hint_data(
419-
display_value_before_backslash,
420-
caret_position - 1,
421-
props.context_file_paths
422-
)
423-
424-
if (hint_data) {
425-
const { word: last_word, path: matched_path } = hint_data
426-
const old_raw_value = props.value
427-
428-
const last_word_in_raw_index = old_raw_value.lastIndexOf(last_word)
429-
if (
430-
last_word_in_raw_index !== -1 &&
431-
old_raw_value.endsWith(last_word)
432-
) {
433-
const value_before = old_raw_value.substring(
434-
0,
435-
last_word_in_raw_index
436-
)
437-
const final_new_value = `${value_before}\`${matched_path}\` `
438-
has_modified_current_entry_ref.current = true
439-
update_value(final_new_value, final_new_value.length)
440-
set_history_index(-1)
441-
return
442-
}
443-
}
444-
}
445-
446412
has_modified_current_entry_ref.current = new_raw_value !== ''
447413
update_value(new_raw_value)
448414

‎packages/ui/src/components/editor/panel/PromptField/utils/get-file-match-hint-data.ts‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)