Skip to content

Commit 9c700c5

Browse files
Merge pull request intersystems-community#1124 from gjsjohnmurray/for-testingmanager
For testingmanager
2 parents 8d1f9c5 + 6eb8306 commit 9c700c5

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/commands/compile.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ async function importFile(
9696
if (typeof file.content === "string") {
9797
enc = false;
9898
content = file.content.split(/\r?\n/);
99+
100+
// Avoid appending a blank line on every save, which would cause a web app file to grow each time
101+
if (content.length > 1 && content[content.length - 1] === "") {
102+
content.pop();
103+
}
99104
} else {
100105
// Base64 encoding must be in chunk size multiple of 3 and within the server's potential 32K string limit
101106
// Output is 4 chars for each 3 input, so 24573/3*4 = 32764
@@ -346,6 +351,10 @@ export async function importAndCompile(
346351
fileSystemProvider.fireFileChanged(file.uri);
347352
}
348353
}
354+
} else if (file.uri.scheme === FILESYSTEM_SCHEMA || file.uri.scheme === FILESYSTEM_READONLY_SCHEMA) {
355+
// Fire the file changed event to avoid VSCode alerting the user on the next folder-specific save (e.g. of settings.json) that
356+
// "The content of the file is newer."
357+
fileSystemProvider.fireFileChanged(file.unredirectedUri ?? file.uri);
349358
}
350359
});
351360
}

src/providers/DocumentContentProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export class DocumentContentProvider implements vscode.TextDocumentContentProvid
7777
}
7878
let uri: vscode.Uri;
7979
if (wFolderUri && (wFolderUri.scheme === FILESYSTEM_SCHEMA || wFolderUri.scheme === FILESYSTEM_READONLY_SCHEMA)) {
80+
// Avoid later adding a namespace=XXX queryparam when this is implied by the authority part of the workspace folder uri
81+
// otherwise stopping at a breakpoint would load a second copy of the file
82+
const authorityParts = wFolderUri.authority.split(":");
83+
if (authorityParts.length === 2 && namespace?.toLowerCase() === authorityParts[1]) {
84+
namespace = "";
85+
}
8086
const flat = new URLSearchParams(wFolderUri.query).get("flat") == "1";
8187
const fileExt = name.split(".").pop();
8288
const fileName = name

src/providers/FileSystemProvider/FileSystemProvider.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export type Entry = File | Directory;
2424
export function generateFileContent(fileName: string, sourceContent: Buffer): { content: string[]; enc: boolean } {
2525
const sourceLines = sourceContent.toString().split("\n");
2626
const fileExt = fileName.split(".").pop().toLowerCase();
27-
if (fileExt === "cls") {
27+
const csp = fileName.startsWith("/");
28+
if (fileExt === "cls" && !csp) {
2829
const className = fileName.split(".").slice(0, -1).join(".");
2930
const content: string[] = [];
3031
const preamble: string[] = [];
@@ -48,7 +49,7 @@ export function generateFileContent(fileName: string, sourceContent: Buffer): {
4849
content,
4950
enc: false,
5051
};
51-
} else if (["int", "inc", "mac"].includes(fileExt)) {
52+
} else if (["int", "inc", "mac"].includes(fileExt) && !csp) {
5253
sourceLines.shift();
5354
const routineName = fileName.split(".").slice(0, -1).join(".");
5455
const routineType = fileExt != "mac" ? `[Type=${fileExt.toUpperCase()}]` : "";
@@ -144,6 +145,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
144145
}
145146

146147
public stat(uri: vscode.Uri): Promise<vscode.FileStat> {
148+
uri = redirectDotvscodeRoot(uri);
147149
return this._lookup(uri);
148150
}
149151

@@ -346,7 +348,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
346348
return Promise.reject();
347349
}
348350
// File doesn't exist on the server, and we are allowed to create it.
349-
// Create content (typically a stub).
351+
// Create content (typically a stub, unless the write-phase of a copy operation).
350352
const newContent = generateFileContent(fileName, content);
351353

352354
// Write it to the server
@@ -434,6 +436,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
434436
}
435437

436438
public async delete(uri: vscode.Uri, options: { recursive: boolean }): Promise<void> {
439+
uri = redirectDotvscodeRoot(uri);
437440
const csp = isCSPFile(uri);
438441
const fileName = csp ? uri.path : uri.path.slice(1).replace(/\//g, ".");
439442
const params = new URLSearchParams(uri.query);
@@ -442,7 +445,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
442445
if (fileName.startsWith(".")) {
443446
return;
444447
}
445-
if (await this._lookup(uri).then((entry) => entry instanceof Directory)) {
448+
if (await this._lookup(uri, true).then((entry) => entry instanceof Directory)) {
446449
// Get the list of documents to delete
447450
let toDeletePromise: Promise<any>;
448451
if (project) {
@@ -554,7 +557,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
554557
}
555558
// Write the new file
556559
// This is going to attempt the write regardless of the user's response to the check out prompt
557-
const api = new AtelierAPI(oldUri);
560+
const api = new AtelierAPI(newUri);
558561
await api
559562
.putDoc(
560563
newFileName,

src/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface CurrentFile {
3636
name: string;
3737
fileName: string;
3838
uri: vscode.Uri;
39+
unredirectedUri?: vscode.Uri;
3940
workspaceFolder: string;
4041
uniqueId: string;
4142
}
@@ -284,6 +285,7 @@ export function currentFile(document?: vscode.TextDocument): CurrentTextFile {
284285
fileName,
285286
name,
286287
uri,
288+
unredirectedUri: document.uri,
287289
eol,
288290
workspaceFolder,
289291
uniqueId,

0 commit comments

Comments
 (0)