Skip to content

Commit 0d4d3de

Browse files
committed
Remove some uses of ignoreFocusOut
1 parent 258a6f5 commit 0d4d3de

File tree

9 files changed

+44
-53
lines changed

9 files changed

+44
-53
lines changed

src/commands/compile.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -748,21 +748,23 @@ export async function importXMLFiles(): Promise<any> {
748748
try {
749749
// Use the server connection from a workspace folder
750750
const wsFolder = await getWsFolder(
751-
"Pick a workspace folder. Server-side folders import from the local file system."
751+
"Pick a workspace folder. Server-side folders import from the local file system.",
752+
false,
753+
false,
754+
false,
755+
true
752756
);
753757
if (!wsFolder) {
754758
if (wsFolder === undefined) {
755759
// Strict equality needed because undefined == null
756-
vscode.window.showErrorMessage("'Import XML Files...' command requires an open workspace.", "Dismiss");
760+
vscode.window.showErrorMessage(
761+
"'Import XML Files...' command requires a workspace folder with an active server connection.",
762+
"Dismiss"
763+
);
757764
}
758765
return;
759766
}
760767
const api = new AtelierAPI(wsFolder.uri);
761-
// Make sure the server connection is active
762-
if (!api.active || api.ns == "") {
763-
vscode.window.showErrorMessage("'Import XML Files...' command requires an active server connection.", "Dismiss");
764-
return;
765-
}
766768
// Make sure the server has the xml endpoints
767769
if (api.config.apiVersion < 7) {
768770
vscode.window.showErrorMessage(

src/commands/export.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -292,26 +292,24 @@ export async function exportCurrentFile(): Promise<any> {
292292
export async function exportDocumentsToXMLFile(): Promise<void> {
293293
try {
294294
// Use the server connection from a workspace folder
295-
const wsFolder = await getWsFolder("Pick a workspace folder. Server-side folders export to the local file system.");
295+
const wsFolder = await getWsFolder(
296+
"Pick a workspace folder. Server-side folders export to the local file system.",
297+
false,
298+
false,
299+
false,
300+
true
301+
);
296302
if (!wsFolder) {
297303
if (wsFolder === undefined) {
298304
// Strict equality needed because undefined == null
299305
vscode.window.showErrorMessage(
300-
"'Export Documents to XML File...' command requires an open workspace.",
306+
"'Export Documents to XML File...' command requires a workspace folder with an active server connection.",
301307
"Dismiss"
302308
);
303309
}
304310
return;
305311
}
306312
const api = new AtelierAPI(wsFolder.uri);
307-
// Make sure the server connection is active
308-
if (!api.active || api.ns == "") {
309-
vscode.window.showErrorMessage(
310-
"'Export Documents to XML File...' command requires an active server connection.",
311-
"Dismiss"
312-
);
313-
return;
314-
}
315313
// Make sure the server has the xml endpoints
316314
if (api.config.apiVersion < 7) {
317315
vscode.window.showErrorMessage(

src/commands/jumpToTagAndOffset.ts

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export async function openErrorLocation(): Promise<void> {
6666
const regex = /^(%?[\p{L}\d]+)?(?:\+(\d+))?\^(%?[\p{L}\d.]+)$/u;
6767
const location = await vscode.window.showInputBox({
6868
title: "Enter the location to open",
69-
ignoreFocusOut: true,
7069
placeHolder: "label+offset^routine",
7170
validateInput: (v) => (regex.test(v.trim()) ? undefined : "Input is not in the format 'label+offset^routine'"),
7271
});

src/commands/project.ts

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export async function pickProject(api: AtelierAPI): Promise<string | undefined>
2525
);
2626
if (projects.length === 0) {
2727
const create = await vscode.window.showQuickPick(["Yes", "No"], {
28-
ignoreFocusOut: true,
2928
title: `Namespace ${ns} on server '${api.serverId}' contains no projects. Create one?`,
3029
});
3130
if (create == "Yes") {
@@ -38,7 +37,6 @@ export async function pickProject(api: AtelierAPI): Promise<string | undefined>
3837
let resolveOnHide = true;
3938
const quickPick = vscode.window.createQuickPick();
4039
quickPick.title = `Select a project in namespace ${ns} on server '${api.serverId}', or click '+' to add one.`;
41-
quickPick.ignoreFocusOut = true;
4240
quickPick.items = projects;
4341
quickPick.buttons = [{ iconPath: new vscode.ThemeIcon("add"), tooltip: "Create new project" }];
4442

@@ -837,7 +835,6 @@ export async function modifyProject(
837835
};
838836
}),
839837
{
840-
ignoreFocusOut: true,
841838
canPickMany: true,
842839
title: `Pick the items to remove from project '${project}'.`,
843840
}

src/commands/serverActions.ts

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export async function serverActions(): Promise<void> {
103103

104104
const namespace = await vscode.window.showQuickPick(allNamespaces, {
105105
title: "Pick the namespace to switch to",
106-
ignoreFocusOut: true,
107106
});
108107

109108
if (namespace) {

src/commands/unitTest.ts

-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ async function runHandler(
402402
}),
403403
{
404404
matchOnDetail: true,
405-
ignoreFocusOut: true,
406405
title: `Cannot ${action} tests from multiple roots at once`,
407406
placeHolder: `Pick a root to ${action} tests from`,
408407
}

src/commands/xmlToUdl.ts

+11-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22
import path = require("path");
33
import { config, OBJECTSCRIPTXML_FILE_SCHEMA, xmlContentProvider } from "../extension";
44
import { AtelierAPI } from "../api";
5-
import { fileExists, handleError, notIsfs, outputChannel } from "../utils";
5+
import { fileExists, getWsFolder, handleError, notIsfs, outputChannel } from "../utils";
66
import { getFileName } from "./export";
77

88
const exportHeader = /^\s*<Export generator="(Cache|IRIS)" version="\d+"/;
@@ -33,7 +33,6 @@ export async function previewXMLAsUDL(textEditor: vscode.TextEditor, auto = fals
3333
}),
3434
{
3535
canPickMany: true,
36-
ignoreFocusOut: true,
3736
title: "Select the documents to preview",
3837
}
3938
);
@@ -96,29 +95,17 @@ export async function extractXMLFileContents(xmlUri?: vscode.Uri): Promise<void>
9695
if (xmlUri) {
9796
wsFolder = vscode.workspace.getWorkspaceFolder(xmlUri);
9897
} else {
99-
// Can only run this command on non-isfs folders with an active server connection
100-
const options = vscode.workspace.workspaceFolders.filter((f) => notIsfs(f.uri) && new AtelierAPI(f.uri).active);
101-
if (options.length == 0) {
102-
vscode.window.showErrorMessage(
103-
"'Extract Documents from XML File...' command requires a non-isfs workspace folder with an active server connection.",
104-
"Dismiss"
105-
);
98+
// Use the server connection from a workspace folder
99+
wsFolder = await getWsFolder("Pick the workspace folder to run the command in", false, false, true, true);
100+
if (!wsFolder) {
101+
if (wsFolder === undefined) {
102+
// Strict equality needed because undefined == null
103+
vscode.window.showErrorMessage(
104+
"'Extract Documents from XML File...' command requires a non-isfs workspace folder with an active server connection.",
105+
"Dismiss"
106+
);
107+
}
106108
return;
107-
} else if (options.length == 1) {
108-
wsFolder = options[0];
109-
} else {
110-
// Prompt the user to select a workspace folder
111-
wsFolder = (
112-
await vscode.window.showQuickPick(
113-
options.map((f) => {
114-
return { label: f.name, wf: f };
115-
}),
116-
{
117-
ignoreFocusOut: true,
118-
title: "Pick the workspace folder to run the command in",
119-
}
120-
)
121-
)?.wf;
122109
}
123110
}
124111
if (!wsFolder) return;

src/extension.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1541,11 +1541,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
15411541
),
15421542
vscode.commands.registerCommand("vscode-objectscript.compileIsfs", (uri) => fileSystemProvider.compile(uri)),
15431543
vscode.commands.registerCommand("vscode-objectscript.openISCDocument", async () => {
1544-
const wsFolder = await getWsFolder("Pick the workspace folder where you want to open a document");
1544+
const wsFolder = await getWsFolder(
1545+
"Pick the workspace folder where you want to open a document",
1546+
false,
1547+
false,
1548+
false,
1549+
true
1550+
);
15451551
if (!wsFolder) {
15461552
if (wsFolder === undefined) {
15471553
// Strict equality needed because undefined == null
1548-
vscode.window.showErrorMessage("No workspace folders are open.", "Dismiss");
1554+
vscode.window.showErrorMessage("No workspace folders with an active server connection are open.", "Dismiss");
15491555
}
15501556
return;
15511557
}

src/utils/index.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ export async function getWsServerConnection(minVersion?: string): Promise<vscode
824824
return vscode.window
825825
.showQuickPick(conns, {
826826
canPickMany: false,
827-
ignoreFocusOut: true,
828827
matchOnDescription: true,
829828
matchOnDetail: true,
830829
title: "Pick a server connection from the current workspace",
@@ -840,20 +839,26 @@ export async function getWsServerConnection(minVersion?: string): Promise<vscode
840839
* @param title An optional custom prompt title.
841840
* @param writableOnly If `true`, only allow the user to pick from writeable folders.
842841
* @param isfsOnly If `true`, only allow the user to pick from `isfs(-readonly)` folders.
842+
* @param notIsfsOnly If `true`, only allow the user to pick from non-`isfs(-readonly)` folders.
843+
* @param active If `true`, only allow the user to pick from folders with an active server connection.
843844
* @returns `undefined` if there were no workspace folders and `null` if the
844845
* user explicitly escaped from the QuickPick.
845846
*/
846847
export async function getWsFolder(
847848
title = "",
848849
writeableOnly = false,
849-
isfsOnly = false
850+
isfsOnly = false,
851+
notIsfsOnly = false,
852+
active = false
850853
): Promise<vscode.WorkspaceFolder | null | undefined> {
851854
if (!vscode.workspace.workspaceFolders?.length) return;
852855
// Apply the filters
853856
const folders = vscode.workspace.workspaceFolders.filter(
854857
(f) =>
855858
(!writeableOnly || (writeableOnly && vscode.workspace.fs.isWritableFileSystem(f.uri.scheme))) &&
856-
(!isfsOnly || (isfsOnly && filesystemSchemas.includes(f.uri.scheme)))
859+
(!isfsOnly || (isfsOnly && filesystemSchemas.includes(f.uri.scheme))) &&
860+
(!notIsfsOnly || (notIsfsOnly && notIsfs(f.uri))) &&
861+
(!active || (active && new AtelierAPI(f.uri).active))
857862
);
858863
if (!folders.length) return;
859864
if (folders.length == 1) return folders[0];
@@ -864,7 +869,6 @@ export async function getWsFolder(
864869
}),
865870
{
866871
canPickMany: false,
867-
ignoreFocusOut: true,
868872
matchOnDetail: true,
869873
title: title || "Pick a workspace folder",
870874
}

0 commit comments

Comments
 (0)