Skip to content

Commit 63353e5

Browse files
authored
Merge branch 'master' into view-update
2 parents c64a362 + 99eb41a commit 63353e5

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,11 @@
14581458
"type": "boolean",
14591459
"default": false
14601460
},
1461+
"objectscript.autoAdjustName": {
1462+
"markdownDescription": "Automatically modify the class name or ROUTINE header to match the file's path when copying or creating a new file. Does not affect `isfs` files.",
1463+
"type": "boolean",
1464+
"default": true
1465+
},
14611466
"objectscript.compileOnSave": {
14621467
"description": "Automatically compile an InterSystems file when saved in the editor.",
14631468
"type": "boolean",

src/commands/webSocketTerminal.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const keys = {
1818
ctrlE: "\x05",
1919
ctrlH: "\x08",
2020
del: "\x1b[3~",
21+
home: "\x1b\x5b\x48",
22+
end: "\x1b\x5b\x46",
2123
};
2224

2325
const actions = {
@@ -168,6 +170,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
168170
outputChannel.appendLine(
169171
typeof error == "string" ? error : error instanceof Error ? error.message : JSON.stringify(error)
170172
);
173+
outputChannel.appendLine("Check that the InterSystems server's web server supports WebSockets.");
171174
outputChannel.show(true);
172175
vscode.window.showErrorMessage(
173176
"Failed to initialize WebSocket Terminal. Check 'ObjectScript' Output channel for details.",
@@ -372,7 +375,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
372375
inputArr[inputArr.length - 1].slice(0, this._cursorCol - this._margin) +
373376
inputArr[inputArr.length - 1].slice(this._cursorCol - this._margin + 1);
374377
this._input = inputArr.join("\r\n");
375-
this._hideCursorWrite(actions.cursorForward + actions.deleteChar + actions.cursorBack);
378+
this._hideCursorWrite(actions.deleteChar);
376379
if (this._input != "" && this._state == "prompt" && this._syntaxColoringEnabled()) {
377380
// Syntax color input
378381
this._socket.send(JSON.stringify({ type: "color", input: this._input }));
@@ -484,6 +487,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
484487
this._state = "eval";
485488
return;
486489
}
490+
case keys.home:
487491
case keys.ctrlA: {
488492
if (this._state == "prompt" && this._cursorCol - this._margin > 0) {
489493
// Move the cursor to the beginning of the line
@@ -492,6 +496,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
492496
}
493497
return;
494498
}
499+
case keys.end:
495500
case keys.ctrlE: {
496501
if (this._state == "prompt") {
497502
// Move the cursor to the end of the line

src/extension.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10451045
RESTDebugPanel.create(context.extensionUri)
10461046
),
10471047
vscode.commands.registerCommand("vscode-objectscript.exportCurrentFile", exportCurrentFile),
1048-
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) =>
1049-
Promise.all(
1048+
vscode.workspace.onDidCreateFiles((e: vscode.FileCreateEvent) => {
1049+
if (!config("autoAdjustName")) return;
1050+
return Promise.all(
10501051
e.files
10511052
.filter((uri) => !filesystemSchemas.includes(uri.scheme))
10521053
.filter((uri) => ["cls", "inc", "int", "mac"].includes(uri.path.split(".").pop().toLowerCase()))
@@ -1078,8 +1079,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10781079
// Write the new content to the file
10791080
return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n")));
10801081
})
1081-
)
1082-
),
1082+
);
1083+
}),
10831084
vscode.window.onDidChangeActiveTextEditor((editor: vscode.TextEditor) => {
10841085
if (config("openClassContracted") && editor && editor.document.languageId === "objectscript-class") {
10851086
const uri: string = editor.document.uri.toString();

src/providers/FileSystemProvider/TextSearchProvider.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ function searchMatchToLine(
149149
// This is in the class description
150150
line = descLineToDocLine(content, match.attrline, i);
151151
break;
152-
} else if (match.attr == "Super") {
153-
// This is a superclass
152+
} else if (match.attr == "Super" || match.attr == "Name") {
153+
// This is in the class definition line
154154
if (content[i].includes(match.text)) {
155155
line = i;
156156
}
@@ -306,7 +306,18 @@ export class TextSearchProvider implements vscode.TextSearchProvider {
306306

307307
/** Report matches in `file` to the user */
308308
const reportMatchesForFile = async (file: SearchResult): Promise<void> => {
309-
if (token.isCancellationRequested) {
309+
// The last three checks are needed to protect against
310+
// bad output from the server due to a bug.
311+
if (
312+
// The user cancelled the search
313+
token.isCancellationRequested ||
314+
// The server reported no matches in this file
315+
!file.matches.length ||
316+
// The file name is malformed
317+
(file.doc.includes("/") && !/^\/(?:[^/]+\/)+[^/.]*(?:\.[^/.]+)+$/.test(file.doc)) ||
318+
(!file.doc.includes("/") &&
319+
!/^(%?[\p{L}\d\u{100}-\u{ffff}]+(?:\.[\p{L}\d\u{100}-\u{ffff}]+)+)$/u.test(file.doc))
320+
) {
310321
return;
311322
}
312323

0 commit comments

Comments
 (0)