@@ -3,10 +3,12 @@ import type { DisplayResult } from '../../../types'
33import {
44 acceptChangeAndRefresh ,
55 acceptFileChanges ,
6+ dismissOneMatch ,
7+ dismissOneFile ,
68} from '../../hooks/useSearch'
79
810import * as stylex from '@stylexjs/stylex'
9- import { VscReplace , VscReplaceAll } from 'react-icons/vsc'
11+ import { VscReplace , VscReplaceAll , VscClose } from 'react-icons/vsc'
1012
1113const styles = stylex . create ( {
1214 list : {
@@ -33,7 +35,7 @@ const styles = stylex.create({
3335 marginLeft : '0.4em' ,
3436 } ,
3537 ':last-child' : {
36- marginRight : '0.4em ' ,
38+ marginRight : '0.2em ' ,
3739 } ,
3840 } ,
3941} )
@@ -56,14 +58,20 @@ export function MatchActions({ className: parent, match }: ActionsProps) {
5658 ] ,
5759 } )
5860 } , [ match ] )
59- if ( ! match . replacement ) {
60- return null
61- }
61+ const onDismiss = useCallback ( ( ) => {
62+ dismissOneMatch ( match )
63+ } , [ match ] )
6264 return (
6365 < ul className = { `${ local } ${ parent } ` } role = "toolbar" >
6466 { /* VSCode supports shortcut Replace (⇧⌘1)*/ }
65- < li { ...stylex . props ( styles . action ) } onClick = { onClick } >
66- < VscReplace role = "button" title = "Replace" tabIndex = { 0 } />
67+ { match . replacement ? (
68+ < li { ...stylex . props ( styles . action ) } onClick = { onClick } >
69+ < VscReplace role = "button" title = "Replace" tabIndex = { 0 } />
70+ </ li >
71+ ) : null }
72+ { /* VSCode supports shortcut Dismiss (⌘Backspace)*/ }
73+ < li { ...stylex . props ( styles . action ) } onClick = { onDismiss } >
74+ < VscClose role = "button" title = "Dismiss" tabIndex = { 0 } />
6775 </ li >
6876 </ ul >
6977 )
@@ -88,14 +96,24 @@ export function FileActions({
8896 } ,
8997 [ filePath ] ,
9098 )
91- if ( ! hasReplace ) {
92- return null
93- }
99+ const onDismiss = useCallback (
100+ ( e : MouseEvent < HTMLLIElement > ) => {
101+ e . stopPropagation ( )
102+ dismissOneFile ( filePath )
103+ } ,
104+ [ filePath ] ,
105+ )
94106 return (
95107 < ul className = { `${ local } ${ parent } ` } role = "toolbar" >
96108 { /* VSCode supports shortcut Replace (⇧⌘1)*/ }
97- < li { ...stylex . props ( styles . action ) } onClick = { onClick } >
98- < VscReplaceAll role = "button" title = "Replace All" tabIndex = { 0 } />
109+ { hasReplace && (
110+ < li { ...stylex . props ( styles . action ) } onClick = { onClick } >
111+ < VscReplaceAll role = "button" title = "Replace All" tabIndex = { 0 } />
112+ </ li >
113+ ) }
114+ { /* VSCode supports shortcut Dismiss (⌘Backspace)*/ }
115+ < li { ...stylex . props ( styles . action ) } onClick = { onDismiss } >
116+ < VscClose role = "button" title = "Dismiss" tabIndex = { 0 } />
99117 </ li >
100118 </ ul >
101119 )
0 commit comments