@@ -2,7 +2,12 @@ import path from 'node:path'
22import { type ExtensionContext , commands , workspace , window } from 'vscode'
33import { type ChildProcessWithoutNullStreams , spawn } from 'node:child_process'
44
5- import { parentPort , resolveBinary , streamedPromise } from './common'
5+ import {
6+ parentPort ,
7+ resolveBinary ,
8+ streamedPromise ,
9+ normalizeCommandForWindows ,
10+ } from './common'
611import type { SgSearch , DisplayResult , SearchQuery } from '../types'
712
813/**
@@ -114,9 +119,7 @@ export function buildCommand(query: SearchQuery) {
114119 return
115120 }
116121 const command = resolveBinary ( )
117- // windows user may input space in command
118- const normalizedCommand =
119- / \s / . test ( command ) && ! command . endsWith ( '.exe' ) ? `"${ command } "` : command
122+ const { normalizedCommand, shell } = normalizeCommandForWindows ( command )
120123 const uris = workspace . workspaceFolders ?. map ( i => i . uri ?. fsPath ) ?? [ ]
121124 const args = [ 'run' , '--pattern' , pattern , '--json=stream' ]
122125 if ( query . selector ) {
@@ -141,9 +144,7 @@ export function buildCommand(query: SearchQuery) {
141144 console . debug ( 'running' , query , normalizedCommand , args )
142145 // TODO: multi-workspaces support
143146 return spawn ( normalizedCommand , args , {
144- // for windows
145- shell :
146- process . platform === 'win32' && ! command . toLowerCase ( ) . endsWith ( '.exe' ) ,
147+ shell,
147148 cwd : uris [ 0 ] ,
148149 } )
149150}
0 commit comments