Skip to content

Commit 64627a2

Browse files
author
Tyler Deemer
committed
Merge branch 'master'
2 parents 6a25637 + 6619739 commit 64627a2

File tree

5 files changed

+55
-38
lines changed

5 files changed

+55
-38
lines changed

src/api/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import {
88
getResolvedConnectionSpec,
99
config,
1010
extensionContext,
11-
FILESYSTEM_SCHEMA,
12-
FILESYSTEM_READONLY_SCHEMA,
1311
workspaceState,
1412
panel,
1513
checkConnection,
14+
schemas,
1615
} from "../extension";
1716
import { currentWorkspaceFolder, outputConsole, outputChannel } from "../utils";
1817

@@ -93,7 +92,7 @@ export class AtelierAPI {
9392
let namespace = "";
9493
if (wsOrFile) {
9594
if (wsOrFile instanceof vscode.Uri) {
96-
if (wsOrFile.scheme === FILESYSTEM_SCHEMA || wsOrFile.scheme === FILESYSTEM_READONLY_SCHEMA) {
95+
if (schemas.includes(wsOrFile.scheme)) {
9796
workspaceFolderName = wsOrFile.authority;
9897
const { query } = url.parse(decodeURIComponent(wsOrFile.toString()), true);
9998
if (query) {

src/commands/compile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ export async function importAndCompile(askFLags = false, document?: vscode.TextD
202202
if (!file) {
203203
return;
204204
}
205-
if (!config("conn").active) {
205+
206+
// Do nothing if it is a local file and objectscript.conn.active is false
207+
if (document.uri.scheme === "file" && !config("conn").active) {
206208
return;
207209
}
208210

src/commands/studio.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ class StudioActions {
286286
.then(() => resolve())
287287
.catch((err) => {
288288
console.log(err);
289-
outputChannel.appendLine(`Studio Action "${action.label}" not supported`);
289+
outputChannel.appendLine(
290+
`Studio Action "${action.label}" not supported on ${this.api.config.host}:${this.api.config.port}[${this.api.config.ns}]`
291+
);
290292
outputChannel.show();
291293
reject();
292294
});

src/extension.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ export function checkConnection(clearCookies = false, uri?: vscode.Uri): void {
238238
/// Use xdebug's websocket, to catch when server disconnected
239239
connectionSocket = new WebSocket(api.xdebugUrl());
240240
connectionSocket.onopen = () => {
241-
fireOtherStudioAction(OtherStudioAction.ConnectedToNewNamespace);
241+
fireOtherStudioAction(
242+
OtherStudioAction.ConnectedToNewNamespace,
243+
typeof apiTarget === "string" ? undefined : apiTarget
244+
);
242245
panel.text = `${connInfo} - Connected`;
243246
};
244247
connectionSocket.onclose = (event) => {

src/providers/FileSystemPovider/FileSystemProvider.ts

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -132,40 +132,51 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
132132
return;
133133
}
134134
const api = new AtelierAPI(uri);
135-
return this._lookupAsFile(uri)
136-
.then(() => Promise.reject())
137-
.catch((error) => {
138-
if (error.code === "FileNotFound") {
139-
return;
135+
return this._lookupAsFile(uri).then(
136+
() => {
137+
// Weirdly, if the file exists on the server we don't actually write its content here.
138+
// Instead we simply return as though we succeeded. The actual writing is done by our
139+
// workspace.onDidSaveTextDocument handler.
140+
return;
141+
},
142+
(error) => {
143+
if (error.code !== "FileNotFound" || !options.create) {
144+
return Promise.reject();
140145
}
141-
return Promise.reject();
142-
})
143-
.then(() => {
146+
// File doesn't exist on the server, and we are allowed to create it.
147+
// Create content (typically a stub).
144148
const newContent = this.generateFileContent(fileName, content);
145-
return api.putDoc(
146-
fileName,
147-
{
148-
...newContent,
149-
mtime: Date.now(),
150-
},
151-
false
152-
);
153-
})
154-
.catch((error) => {
155-
if (error.error?.result?.status) {
156-
throw vscode.FileSystemError.Unavailable(error.error.result.status);
157-
}
158-
throw vscode.FileSystemError.Unavailable(error.message);
159-
})
160-
.then((response) => {
161-
if (response && response.result.ext && response.result.ext[0] && response.result.ext[1]) {
162-
fireOtherStudioAction(OtherStudioAction.CreatedNewDocument, uri, response.result.ext[0]);
163-
fireOtherStudioAction(OtherStudioAction.FirstTimeDocumentSave, uri, response.result.ext[1]);
164-
}
165-
this._lookupAsFile(uri).then((entry) => {
166-
this._fireSoon({ type: vscode.FileChangeType.Changed, uri });
167-
});
168-
});
149+
150+
// Write it to the server
151+
return api
152+
.putDoc(
153+
fileName,
154+
{
155+
...newContent,
156+
mtime: Date.now(),
157+
},
158+
false
159+
)
160+
.catch((error) => {
161+
// Throw all failures
162+
if (error.error?.result?.status) {
163+
throw vscode.FileSystemError.Unavailable(error.error.result.status);
164+
}
165+
throw vscode.FileSystemError.Unavailable(error.message);
166+
})
167+
.then((response) => {
168+
// New file has been written
169+
if (response && response.result.ext && response.result.ext[0] && response.result.ext[1]) {
170+
fireOtherStudioAction(OtherStudioAction.CreatedNewDocument, uri, response.result.ext[0]);
171+
fireOtherStudioAction(OtherStudioAction.FirstTimeDocumentSave, uri, response.result.ext[1]);
172+
}
173+
// Sanity check that we find it there, then make client side update things
174+
this._lookupAsFile(uri).then(() => {
175+
this._fireSoon({ type: vscode.FileChangeType.Changed, uri });
176+
});
177+
});
178+
}
179+
);
169180
}
170181

171182
public delete(uri: vscode.Uri, options: { recursive: boolean }): void | Thenable<void> {

0 commit comments

Comments
 (0)