File tree Expand file tree Collapse file tree
ui/src/components/editor/panel/PromptField
vscode/src/views/panel/frontend/Home Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -170,19 +170,10 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
170170
171171 useEffect ( ( ) => {
172172 if ( input_ref . current && input_ref . current . innerHTML !== highlighted_html ) {
173- const selection = window . getSelection ( )
174- const should_restore_caret =
175- document . activeElement === input_ref . current &&
176- selection &&
177- selection . rangeCount > 0 &&
178- selection . anchorNode &&
179- input_ref . current . contains ( selection . anchorNode )
180-
181- const selection_start = should_restore_caret
182- ? get_caret_position_from_div ( input_ref . current )
183- : 0
173+ const is_focused = document . activeElement === input_ref . current
174+ const selection_start = get_caret_position_from_div ( input_ref . current )
184175 input_ref . current . innerHTML = highlighted_html
185- if ( should_restore_caret ) {
176+ if ( is_focused ) {
186177 set_caret_position_for_div ( input_ref . current , selection_start )
187178 }
188179 }
Original file line number Diff line number Diff line change @@ -55,13 +55,8 @@ export const Home: React.FC<Props> = (props) => {
5555 handle_change,
5656 handle_add,
5757 handle_add_subtask,
58- handle_delete,
59- handle_forward
60- } = use_tasks (
61- props . on_tasks_change ,
62- props . on_task_delete ,
63- props . on_task_forward
64- )
58+ handle_delete
59+ } = use_tasks ( props . on_tasks_change , props . on_task_delete )
6560
6661 const { is_timeline_reached, timeline_ref, handle_scroll_to_timeline } =
6762 use_timeline_scroll ( )
@@ -247,7 +242,7 @@ export const Home: React.FC<Props> = (props) => {
247242 handle_delete ( workspace_root_folder , timestamp )
248243 } }
249244 on_forward = { ( text ) => {
250- handle_forward ( text )
245+ props . on_task_forward ( text )
251246 } }
252247 />
253248 ) }
Original file line number Diff line number Diff line change @@ -37,8 +37,7 @@ const add_subtask_to_tree = (
3737
3838export const use_tasks = (
3939 on_tasks_change : ( root : string , tasks : Task [ ] ) => void ,
40- on_task_delete : ( root : string , timestamp : number ) => void ,
41- on_task_forward : ( text : string ) => void
40+ on_task_delete : ( root : string , timestamp : number ) => void
4241) => {
4342 const handle_reorder = ( root : string , new_tasks : Task [ ] ) => {
4443 on_tasks_change ( root , new_tasks )
@@ -82,16 +81,11 @@ export const use_tasks = (
8281 on_task_delete ( root , timestamp )
8382 }
8483
85- const handle_forward = ( text : string ) => {
86- on_task_forward ( text )
87- }
88-
8984 return {
9085 handle_reorder,
9186 handle_change,
9287 handle_add,
9388 handle_add_subtask,
94- handle_delete,
95- handle_forward
89+ handle_delete
9690 }
9791}
You can’t perform that action at this time.
0 commit comments