@@ -21,7 +21,7 @@ const get_symbol_ranges = (
2121 const ranges : { start : number ; end : number } [ ] = [ ]
2222 // This regex is a combination of all symbol types
2323 const regex =
24- / ` ( [ ^ \s ` ] * \. [ ^ \s ` ] + ) ` | ( # C h a n g e s \( [ ^ ) ] + \) ) | ( # S e l e c t i o n ) | ( # S a v e d C o n t e x t \( (?: W o r k s p a c e S t a t e | J S O N ) " (?: \\ .| [ ^ " \\ ] ) * " \) ) | ( # (?: C o m m i t | C o n t e x t A t C o m m i t ) \( [ ^ : ] + : [ ^ \s " ] + " (?: \\ .| [ ^ " \\ ] ) * " \) ) | ( < f r a g m e n t p a t h = " [ ^ " ] + " (?: [ ^ > ] + ) ? > [ \s \S ] * ?< \/ f r a g m e n t > ) | ( # S k i l l \( [ ^ ) ] + \) ) | ( # I m a g e \( [ a - f A - F 0 - 9 ] + \) ) | ( # D o c u m e n t \( [ a - f A - F 0 - 9 ] + \) ) | ( # W e b s i t e \( [ ^ ) ] + \) ) / g
24+ / ` ( [ ^ \s ` ] * \. [ ^ \s ` ] + ) ` | ( # C h a n g e s \( [ ^ ) ] + \) ) | ( # S e l e c t i o n ) | ( # S a v e d C o n t e x t \( (?: W o r k s p a c e S t a t e | J S O N ) " (?: \\ .| [ ^ " \\ ] ) * " \) ) | ( # (?: C o m m i t | C o n t e x t A t C o m m i t ) \( [ ^ : ] + : [ ^ \s " ] + " (?: \\ .| [ ^ " \\ ] ) * " \) ) | ( < f r a g m e n t p a t h = " [ ^ " ] + " (?: [ ^ > ] + ) ? > [ \s \S ] * ?< \/ f r a g m e n t > ) | ( # S k i l l \( [ ^ ) ] + \) ) | ( # I m a g e \( [ a - f A - F 0 - 9 ] + \) ) | ( # D o c u m e n t \( [ a - f A - F 0 - 9 ] + : \d + \) ) | ( # W e b s i t e \( [ ^ ) ] + \) ) / g
2525
2626 let match
2727 while ( ( match = regex . exec ( text ) ) !== null ) {
@@ -77,7 +77,7 @@ const reconstruct_raw_value_from_node = (node: Node): string => {
7777 const contextType = el . dataset . contextType
7878 const contextName = el . dataset . contextName
7979 if ( ! contextType || ! contextName ) return ''
80- const expected_text = `Context "${ contextName } " `
80+ const expected_text = `Context "${ contextName } `
8181 const index = inner_content . indexOf ( expected_text )
8282 if ( index != - 1 ) {
8383 const prefix = inner_content . substring ( 0 , index )
@@ -178,14 +178,15 @@ const reconstruct_raw_value_from_node = (node: Node): string => {
178178 }
179179 } else if ( el . dataset . type == 'document-symbol' ) {
180180 const hash = el . dataset . hash
181- if ( ! hash ) return ''
181+ const token_count = el . dataset . tokenCount
182+ if ( ! hash || ! token_count ) return ''
182183
183- const expected_text = `Document `
184+ const expected_text = `Pasted ${ token_count } tokens `
184185 const index = inner_content . indexOf ( expected_text )
185186 if ( index != - 1 ) {
186187 const prefix = inner_content . substring ( 0 , index )
187188 const suffix = inner_content . substring ( index + expected_text . length )
188- return `${ prefix } #Document(${ hash } )${ suffix } `
189+ return `${ prefix } #Document(${ hash } : ${ token_count } )${ suffix } `
189190 }
190191 } else if ( el . dataset . type == 'website-symbol' ) {
191192 const url = el . dataset . url
@@ -456,9 +457,10 @@ export const use_handlers = (
456457 }
457458 } else if ( symbol_type == 'document-symbol' ) {
458459 const hash = symbol_element . dataset . hash
459- if ( ! hash ) return
460+ const token_count = symbol_element . dataset . tokenCount
461+ if ( ! hash || ! token_count ) return
460462
461- const search_pattern = `#Document(${ hash } )`
463+ const search_pattern = `#Document(${ hash } : ${ token_count } )`
462464 const start_index = props . value . indexOf ( search_pattern )
463465
464466 if ( start_index != - 1 ) {
@@ -640,14 +642,15 @@ export const use_handlers = (
640642
641643 const text = e . clipboardData . getData ( 'text/plain' )
642644
643- if ( / ^ h t t p s ? : \/ \/ [ ^ \s ] + $ / . test ( text . trim ( ) ) ) {
644- e . preventDefault ( )
645+ if (
646+ ! is_shift_pressed_ref . current &&
647+ / ^ h t t p s ? : \/ \/ [ ^ \s ] + $ / . test ( text . trim ( ) )
648+ ) {
645649 props . on_paste_url ( text . trim ( ) )
646650 return
647651 }
648652
649- if ( text . length > 1000 ) {
650- e . preventDefault ( )
653+ if ( ! is_shift_pressed_ref . current && text . length > 1000 ) {
651654 props . on_paste_document ( text )
652655 return
653656 }
@@ -993,7 +996,9 @@ export const use_handlers = (
993996
994997 const handle_document_symbol_deletion = ( raw_pos : number ) : boolean => {
995998 const text_before_cursor = props . value . substring ( 0 , raw_pos )
996- const match = text_before_cursor . match ( / # D o c u m e n t \( ( [ a - f A - F 0 - 9 ] + ) \) $ / )
999+ const match = text_before_cursor . match (
1000+ / # D o c u m e n t \( ( [ a - f A - F 0 - 9 ] + ) (?: ( \d + ) ) ? \) $ /
1001+ )
9971002
9981003 if ( match ) {
9991004 const start_of_match = raw_pos - match [ 0 ] . length
0 commit comments