Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Improve DCD import adding/removing
Browse files Browse the repository at this point in the history
Avoids sending over duplicates
  • Loading branch information
WebFreak001 committed Apr 30, 2020
1 parent 6a3260e commit c9a2c29
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion source/workspaced/com/dcd.d
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,16 @@ class DCDComponent : ComponentWrapper
/// Manually adds import paths as string array
void addImports(string[] imports)
{
knownImports ~= imports;
knownImports = multiwayUnion([knownImports.filterNonEmpty, imports.filterNonEmpty]).array;
updateImports();
}

/// Manually removes import paths using a string array. Note that trying to
/// remove import paths from the import paths provider will result in them
/// being readded as soon as refreshImports is called again.
void removeImports(string[] imports)
{
knownImports = setDifference(knownImports, imports.filterNonEmpty).array;
updateImports();
}

Expand Down Expand Up @@ -888,3 +897,8 @@ struct DCDSearchResult
///
string type;
}

private auto filterNonEmpty(T)(T range)
{
return range.filter!(a => a.length);
}

0 comments on commit c9a2c29

Please sign in to comment.