@@ -22,7 +22,7 @@ const getKeywordRanges = (
2222 const ranges : { start : number ; end : number } [ ] = [ ]
2323 // This regex is a combination of all keyword types
2424 const regex =
25- / ` ( [ ^ \s ` ] * \. [ ^ \s ` ] + ) ` | ( # C h a n g e s : [ ^ \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 ) \s + " [ ^ " ] + " ) | ( # C o m m i t : [ ^ : ] + : [ ^ \s " ] + \s + " [ ^ " ] * " ) / g
25+ / ` ( [ ^ \s ` ] * \. [ ^ \s ` ] + ) ` | ( # C h a n g e s : [ ^ \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 ) \s + " [ ^ " ] + " ) | ( # (?: C o m m i t | C o n t e x t A t C o m m i t ) : [ ^ : ] + : [ ^ \s " ] + \s + " [ ^ " ] * " ) / g
2626
2727 let match
2828 while ( ( match = regex . exec ( text ) ) !== null ) {
@@ -104,6 +104,20 @@ const reconstruct_raw_value_from_node = (node: Node): string => {
104104 }
105105 break
106106 }
107+ case 'contextatcommit-keyword' : {
108+ const repo_name = el . dataset . repoName
109+ const commit_hash = el . dataset . commitHash
110+ const commit_message = el . dataset . commitMessage
111+ if ( ! repo_name || ! commit_hash || commit_message === undefined ) {
112+ return ''
113+ }
114+ const short_hash = commit_hash . substring ( 0 , 7 )
115+ if ( el . textContent ?. startsWith ( short_hash ) ) {
116+ const extra = el . textContent . substring ( short_hash . length )
117+ return `#ContextAtCommit:${ repo_name } :${ commit_hash } "${ commit_message } "${ extra } `
118+ }
119+ break
120+ }
107121 }
108122
109123 if ( el . childNodes . length > 0 ) {
@@ -276,6 +290,23 @@ export const use_handlers = (
276290 const search_pattern = `#Commit:${ repo_name } :${ commit_hash } "${ commit_message } "`
277291 const start_index = props . value . indexOf ( search_pattern )
278292
293+ if ( start_index !== - 1 ) {
294+ apply_keyword_deletion (
295+ start_index ,
296+ start_index + search_pattern . length
297+ )
298+ }
299+ break
300+ }
301+ case 'contextatcommit-keyword' : {
302+ const repo_name = keyword_element . dataset . repoName
303+ const commit_hash = keyword_element . dataset . commitHash
304+ const commit_message = keyword_element . dataset . commitMessage
305+ if ( ! repo_name || ! commit_hash || commit_message === undefined ) return
306+
307+ const search_pattern = `#ContextAtCommit:${ repo_name } :${ commit_hash } "${ commit_message } "`
308+ const start_index = props . value . indexOf ( search_pattern )
309+
279310 if ( start_index !== - 1 ) {
280311 apply_keyword_deletion (
281312 start_index ,
@@ -538,7 +569,9 @@ export const use_handlers = (
538569 context_file_paths : string [ ]
539570 ) : boolean => {
540571 const text_before_cursor = props . value . substring ( 0 , raw_pos )
541- const match = text_before_cursor . match ( / # C o m m i t : [ ^ : ] + : [ ^ \s " ] + \s + " [ ^ " ] * " $ / )
572+ const match = text_before_cursor . match (
573+ / # (?: C o m m i t | C o n t e x t A t C o m m i t ) : [ ^ : ] + : [ ^ \s " ] + \s + " [ ^ " ] * " $ /
574+ )
542575
543576 if ( match ) {
544577 const start_of_match = raw_pos - match [ 0 ] . length
@@ -563,23 +596,26 @@ export const use_handlers = (
563596 context_file_paths
564597 )
565598
566- if ( el . dataset . type === 'file-keyword' ) {
599+ if ( el . dataset . type == 'file-keyword' ) {
567600 return handle_file_keyword_deletion ( raw_pos , context_file_paths )
568601 }
569602
570- if ( el . dataset . type === 'changes-keyword' ) {
603+ if ( el . dataset . type == 'changes-keyword' ) {
571604 return handle_changes_keyword_deletion ( raw_pos , context_file_paths )
572605 }
573606
574- if ( el . dataset . type === 'saved-context-keyword' ) {
607+ if ( el . dataset . type == 'saved-context-keyword' ) {
575608 return handle_saved_context_keyword_deletion ( raw_pos , context_file_paths )
576609 }
577610
578- if ( el . dataset . type === 'selection-keyword' ) {
611+ if ( el . dataset . type == 'selection-keyword' ) {
579612 return handle_selection_keyword_deletion ( raw_pos , context_file_paths )
580613 }
581614
582- if ( el . dataset . type === 'commit-keyword' ) {
615+ if (
616+ el . dataset . type == 'commit-keyword' ||
617+ el . dataset . type == 'contextatcommit-keyword'
618+ ) {
583619 return handle_commit_keyword_deletion ( raw_pos , context_file_paths )
584620 }
585621
@@ -619,7 +655,8 @@ export const use_handlers = (
619655 parent . dataset . type == 'changes-keyword' ||
620656 parent . dataset . type == 'selection-keyword' ||
621657 parent . dataset . type == 'saved-context-keyword' ||
622- parent . dataset . type == 'commit-keyword'
658+ parent . dataset . type == 'commit-keyword' ||
659+ parent . dataset . type == 'contextatcommit-keyword'
623660 ) {
624661 const rangeAfter = document . createRange ( )
625662 rangeAfter . selectNodeContents ( parent )
@@ -639,11 +676,12 @@ export const use_handlers = (
639676 ) {
640677 const el = node_before_cursor as HTMLElement
641678 if (
642- el . dataset . type === 'file-keyword' ||
643- el . dataset . type === 'changes-keyword' ||
644- el . dataset . type === 'selection-keyword' ||
645- el . dataset . type === 'saved-context-keyword' ||
646- el . dataset . type === 'commit-keyword'
679+ el . dataset . type == 'file-keyword' ||
680+ el . dataset . type == 'changes-keyword' ||
681+ el . dataset . type == 'selection-keyword' ||
682+ el . dataset . type == 'saved-context-keyword' ||
683+ el . dataset . type == 'commit-keyword' ||
684+ el . dataset . type == 'contextatcommit-keyword'
647685 ) {
648686 const display_pos = get_caret_position_from_div ( input_ref . current )
649687 if ( handle_keyword_deletion_by_backspace ( el , display_pos ) ) {
0 commit comments