Skip to content

Commit

Permalink
fix: prevent add the same file multiple times to quickfix, resolve #585
Browse files Browse the repository at this point in the history
  • Loading branch information
weirongxu committed Jun 12, 2024
1 parent a385b71 commit 0c02cae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/actions/globalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,16 +784,24 @@ export function loadGlobalActions(action: ActionExplorer) {
async ({ args, nodes, source }) => {
const argAction = (args[0] ?? 'replace') as QuickfixAction;
const action = { add: 'a', replace: 'r' }[argAction];
const list: { filename?: string }[] = await nvim.call('getqflist');
const existFullpathes = list
.map((it) => it.filename)
.filter(Boolean) as string[];
await nvim.call('setqflist', [
nodes
.filter((it) => it.fullpath && !it.expandable)
.map((it) => {
const realtive = pathLib.relative(source.root, it.fullpath!);
const fullpath = it.fullpath!;
if (existFullpathes.includes(fullpath)) return undefined;
const realtive = pathLib.relative(source.root, fullpath);
return {
filename: it.fullpath,
text: realtive,
lnum: 1,
};
}),
})
.filter(Boolean),
action,
]);
const openCommand = (await nvim.getVar(
Expand Down

0 comments on commit 0c02cae

Please sign in to comment.