diff --git a/src/lib/ripgrep.ts b/src/lib/ripgrep.ts index fe7e34a..8601671 100644 --- a/src/lib/ripgrep.ts +++ b/src/lib/ripgrep.ts @@ -8,6 +8,7 @@ import { QPItemQuery, RgLine } from '../types'; import { log, notifyError } from '../utils/log'; import { createResultItem } from '../utils/quickpickUtils'; import { handleNoResultsFound } from './editorActions'; +import { parse } from 'path'; export function rgCommand(value: string, extraFlags?: string[]) { let config = getConfig(); @@ -63,10 +64,10 @@ export function search(value: string, rgExtraFlags?: string[]) { if (parsedLine?.type === 'match') { // eslint-disable-next-line @typescript-eslint/naming-convention - const { path, lines, line_number, absolute_offset } = parsedLine.data; + const { path, lines, line_number } = parsedLine.data; const filePath = path.text; const linePos = line_number; - let colPos = absolute_offset === 0 ? 1 : absolute_offset + 1; + const colPos = parsedLine.data.submatches[0].start + 1; const textResult = lines.text.trim(); const resultItem = { diff --git a/src/types/index.ts b/src/types/index.ts index 337a2f8..e7a4065 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -38,5 +38,12 @@ export type RgLine = { line_number: number // eslint-disable-next-line @typescript-eslint/naming-convention absolute_offset: number + submatches: { + end: number + match: { + text: string + } + start: number + }[] } }; \ No newline at end of file