Skip to content

Commit 98b2bae

Browse files
committed
Add ignore_file_paths option to get_symbol_ranges to bypass file checks during paste handling
- when pasting text containing a file path, it's not pasted to the sybol, but as if were pasted with 'shift' - that's incorrect, the fact of a valid file path should be ignored └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent d4086e2 commit 98b2bae

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export const create_handle_paste =
111111
const has_symbols =
112112
get_symbol_ranges({
113113
text,
114-
selected_files: props.selected_files ?? []
114+
selected_files: props.selected_files ?? [],
115+
ignore_file_paths: true
115116
}).length > 0
116117

117118
if (

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
export const get_symbol_ranges = (params: {
88
text: string
99
selected_files: string[]
10+
ignore_file_paths?: boolean
1011
}): { start: number; end: number }[] => {
1112
const ranges: { start: number; end: number }[] = []
1213
const regex =
@@ -17,7 +18,7 @@ export const get_symbol_ranges = (params: {
1718
const file_path = match[1]
1819

1920
if (file_path) {
20-
if (params.selected_files.includes(file_path)) {
21+
if (!params.ignore_file_paths && params.selected_files.includes(file_path)) {
2122
ranges.push({ start: match.index, end: match.index + match[0].length })
2223
}
2324
} else {

0 commit comments

Comments
 (0)