|
|
@ -26,7 +26,7 @@ export const createWindow = async (dir?: string): Promise<void> => { |
|
|
|
preload: path.join(__dirname, 'preload.js') |
|
|
|
preload: path.join(__dirname, 'preload.js') |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
if(dir && dir.endsWith('/')) dir = dir.slice(0, -1) |
|
|
|
if (dir && dir.endsWith('/')) dir = dir.slice(0, -1) |
|
|
|
let params = dir ? `?opendir=${encodeURIComponent(dir)}` : ''; |
|
|
|
let params = dir ? `?opendir=${encodeURIComponent(dir)}` : ''; |
|
|
|
// and load the index.html of the app.
|
|
|
|
// and load the index.html of the app.
|
|
|
|
mainWindow.loadURL( |
|
|
|
mainWindow.loadURL( |
|
|
@ -35,7 +35,7 @@ export const createWindow = async (dir?: string): Promise<void> => { |
|
|
|
|
|
|
|
|
|
|
|
mainWindow.maximize(); |
|
|
|
mainWindow.maximize(); |
|
|
|
|
|
|
|
|
|
|
|
if(dir){ |
|
|
|
if (dir) { |
|
|
|
mainWindow.setTitle(dir) |
|
|
|
mainWindow.setTitle(dir) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -128,11 +128,106 @@ searchProxy.checkIfSelectStringIsInstalled().then((result) => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
searchProxy.checkIfRgIsInstalled().then((result) => { |
|
|
|
interface position { |
|
|
|
console.log('rg --version', result) |
|
|
|
start: { |
|
|
|
|
|
|
|
line: number |
|
|
|
|
|
|
|
column: number |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
end: { |
|
|
|
|
|
|
|
line: number |
|
|
|
|
|
|
|
column: number |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
).catch((error) => { |
|
|
|
|
|
|
|
console.log('rg --version', error) |
|
|
|
export interface SearchResultLineLine { |
|
|
|
}) |
|
|
|
left: any, |
|
|
|
|
|
|
|
center: any, |
|
|
|
|
|
|
|
right: any, |
|
|
|
|
|
|
|
position: position |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
export interface SearchResultLine { |
|
|
|
|
|
|
|
lines: SearchResultLineLine[] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import * as cp from 'child_process'; |
|
|
|
|
|
|
|
import { rgPath } from '@vscode/ripgrep'; |
|
|
|
|
|
|
|
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('rgDiskPath', rgDiskPath) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ripgrep
|
|
|
|
|
|
|
|
// -s means case sensitive
|
|
|
|
|
|
|
|
// -i means ignore case
|
|
|
|
|
|
|
|
// -F means fixed strings so not regex
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
-g, --glob GLOB ... |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match .gitignore globs. Precede a glob with a ! to exclude it. If multiple globs match a file or directory, the glob given later in the command line takes precedence. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('process.cwd()', process.cwd()) |
|
|
|
|
|
|
|
const child = cp.spawn(rgDiskPath, ['bunsens[a-z]*', '--json', './'], { cwd: process.cwd() }); |
|
|
|
|
|
|
|
child.on('error', (err) => { |
|
|
|
|
|
|
|
console.log('error', err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
child.stdout.on('data', (data) => { |
|
|
|
|
|
|
|
const lines: string[] = data.toString().split('\n') |
|
|
|
|
|
|
|
lines.forEach(line => { |
|
|
|
|
|
|
|
if (line) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = JSON.parse(line) |
|
|
|
|
|
|
|
if (result && result.type && result.type === 'match') { |
|
|
|
|
|
|
|
//console.log('line:', result)
|
|
|
|
|
|
|
|
//console.log('path:', result.data.path.text)
|
|
|
|
|
|
|
|
//console.log('line:', result.data.lines.text)
|
|
|
|
|
|
|
|
//console.log('submatch: ', result.data.submatches)
|
|
|
|
|
|
|
|
let searchResultLine: SearchResultLine = { |
|
|
|
|
|
|
|
lines: [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.data.submatches.forEach((submatch: any) => { |
|
|
|
|
|
|
|
searchResultLine.lines.push({ |
|
|
|
|
|
|
|
left: result.data.lines.text.substring(0, submatch.start), |
|
|
|
|
|
|
|
center: result.data.lines.text.substring(submatch.start, submatch.end), |
|
|
|
|
|
|
|
right: result.data.lines.text.substring(submatch.end), |
|
|
|
|
|
|
|
position: { |
|
|
|
|
|
|
|
start: { |
|
|
|
|
|
|
|
line: result.data.line_number, |
|
|
|
|
|
|
|
column: submatch.start, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
end: { |
|
|
|
|
|
|
|
line: result.data.line_number, |
|
|
|
|
|
|
|
column: submatch.end, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
console.log('searchResultLine', searchResultLine) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
console.log('error ripgrep', e) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//console.log('stdout', lines)
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
child.stderr.on('data', (data) => { |
|
|
|
|
|
|
|
console.log('stderr', data.toString()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
child.on('close', (code) => { |
|
|
|
|
|
|
|
console.log('close', code) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
child.on('exit', (code) => { |
|
|
|
|
|
|
|
console.log('exit', code) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|