File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ import {
1818 TextEditorRevealType ,
1919 TabInputTextDiff ,
2020} from 'vscode'
21- import type { ChildToParent , SearchQuery , SgSearch } from '../types'
21+ import type {
22+ ChildToParent ,
23+ DisplayResult ,
24+ SearchQuery ,
25+ SgSearch ,
26+ } from '../types'
2227import { parentPort , streamedPromise } from './common'
2328import { buildCommand , splitByHighLightToken } from './search'
2429import path from 'path'
@@ -182,20 +187,20 @@ async function refreshSearchResult(
182187 } )
183188 const bytes = await workspace . fs . readFile ( fileUri )
184189 const { receiveResult, conclude } = bufferMaker ( bytes )
190+ const updatedResults : DisplayResult [ ] = [ ]
185191 await streamedPromise ( command ! , ( results : SgSearch [ ] ) => {
186- // TODO, change this
187- parentPort . postMessage ( 'searchResultStreaming' , {
188- id,
189- ...query ,
190- searchResult : results . map ( splitByHighLightToken ) ,
191- } )
192192 for ( const r of results ) {
193193 receiveResult ( r . replacement ! , r . range . byteOffset )
194+ updatedResults . push ( splitByHighLightToken ( r ) )
194195 }
195196 } )
196197 const final = conclude ( )
197198 const replaced = new TextDecoder ( 'utf-8' ) . decode ( final )
198199 previewContents . set ( fileUri . path , replaced )
200+ parentPort . postMessage ( 'refreshSearchResult' , {
201+ id,
202+ updatedResults,
203+ } )
199204}
200205
201206/**
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ export interface ParentToChild {
5454 setIncludeFile : {
5555 includeFile : string
5656 }
57+ refreshSearchResult : {
58+ id : number
59+ updatedResults : DisplayResult [ ]
60+ }
5761}
5862
5963export interface ChildToParent {
You can’t perform that action at this time.
0 commit comments