Skip to content

Commit

Permalink
fix: cursor col position
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmu committed Apr 27, 2024
1 parent ea9bff3 commit a75608e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/ripgrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 = {
Expand Down
7 changes: 7 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}[]
}
};

0 comments on commit a75608e

Please sign in to comment.