Skip to content

Commit 65ac928

Browse files
Keep single-character and numeric pastes inline instead of converting… (#484)
Keep single-character and numeric pastes inline instead of converting them to pasted-text symbols - in prompt field: single characters or numbers should not be converted to #PastedText symbols ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-open-prompt-pasted-text.ts │ │ │ ├── handle-save-prompt-pasted-text.ts │ │ │ └── index.ts │ │ ├── prompt-view-provider.ts │ │ └── utils │ │ └── symbols │ │ ├── pasted-text │ │ │ └── replace-pasted-text-symbol.ts │ │ └── replace-symbols.ts │ ├── frontend │ │ ├── Main │ │ │ ├── Main.tsx │ │ │ └── MainView │ │ │ └── MainView.tsx │ │ ├── Prompt.tsx │ │ └── hooks │ │ └── use-prompt │ │ └── use-prompt.ts │ └── types │ └── messages.ts └── packages ├── shared │ └── src │ └── utils │ └── simplify-prompt-symbols │ ├── simplify-prompt-symbols.spec.ts │ └── simplify-prompt-symbols.ts └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ └── hooks │ └── use-handlers │ ├── handle-input-change.ts │ ├── handle-input-click.ts │ ├── handle-paste.ts │ ├── types.ts │ ├── use-handlers.ts │ └── utils.ts └── shared └── symbols ├── get-highlighted-text.tsx ├── position-mapping.ts ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent 2353f1e commit 65ac928

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • packages/ui/src/components/editor/common/prompts/PromptField/hooks/use-handlers

‎packages/ui/src/components/editor/common/prompts/PromptField/hooks/use-handlers/handle-paste.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ export const create_handle_paste =
117117
ignore_file_paths: true
118118
}).length > 0
119119

120+
const trimmed_text = text.trim()
121+
const is_single_character_or_number =
122+
trimmed_text.length == 1 || /^\d+$/.test(trimmed_text)
123+
120124
if (
121125
!refs.is_shift_pressed_ref.current &&
122-
text.trim().length > 0 &&
126+
trimmed_text.length > 0 &&
123127
!is_fragment_paste &&
124-
!has_symbols
128+
!has_symbols &&
129+
!is_single_character_or_number
125130
) {
126131
const selection = window.getSelection()
127132
if (

0 commit comments

Comments
 (0)