Skip to content

Commit

Permalink
Sort meson.build selection by directory depth first.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfpld committed Nov 16, 2023
1 parent 3e9cd23 commit 7ca7234
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { activateLinters } from "./linters";
import { activateFormatters } from "./formatters";
import { SettingsKey, TaskQuickPickItem } from "./types";
import { createLanguageServerClient } from "./lsp/common";
import { dirname, relative } from "path";
import { dirname, relative, sep } from "path";

export let extensionPath: string;
export let workspaceState: vscode.Memento;
Expand Down Expand Up @@ -237,8 +237,17 @@ export async function activate(ctx: vscode.ExtensionContext) {
if (configureOnOpen) {
let cancel = false;
if (!configurationChosen && mesonFiles.length > 1) {
const items = mesonFiles.map((file, index) => ({ index: index, label: relative(root, file.fsPath) }));
items.sort((a, b) => a.label.localeCompare(b.label));
const items = mesonFiles.map((file, index) => {
const label = relative(root, file.fsPath);
return { index, label, depth: label.split(sep).length };
});
items.sort(function (a, b) {
if (a.depth === b.depth) {
return a.label.localeCompare(b.label);
} else {
return a.depth - b.depth;
}
});
const selection = await vscode.window.showQuickPick(items, {
canPickMany: false,
title: "Select configuration to use.",
Expand Down

0 comments on commit 7ca7234

Please sign in to comment.