function comparePaths()

in src/debugAdapter/helpers.ts [14:32]


function comparePaths(pathA: string, pathB: string): number {
  function pathDiffContainsFolders(pathDiff: string) {
    return pathDiff.indexOf(pathSep) !== -1;
  }

  const pathAdiffByPathB = getPathsDiff(pathA, pathB);
  const pathBdiffByPathA = getPathsDiff(pathB, pathA);
  const isPathAdiffByPathBContainsFolder = pathDiffContainsFolders(pathAdiffByPathB);
  const isPathBdiffByPathBContainsFolder = pathDiffContainsFolders(pathBdiffByPathA);
  if (!isPathAdiffByPathBContainsFolder && isPathBdiffByPathBContainsFolder) {
    return -1;
  } else if (isPathAdiffByPathBContainsFolder && !isPathBdiffByPathBContainsFolder) {
    return 1;
  } else {
    return pathAdiffByPathB < pathBdiffByPathA
      ? -1
      : (pathAdiffByPathB > pathBdiffByPathA ? 1 : 0);
  }
}