Skip to content

Commit 73c9499

Browse files
authored
Merge pull request #638 from isc-bsaviano/fix-309
Add "Edit Other" command and menu option
2 parents 15978c0 + 30c4cd9 commit 73c9499

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

package.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@
214214
{
215215
"command": "vscode-objectscript.compileOnlyWithFlags",
216216
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
217+
},
218+
{
219+
"command": "vscode-objectscript.editOthers",
220+
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive"
217221
}
218222
],
219223
"view/title": [
@@ -285,30 +289,35 @@
285289
"when": "vscode-objectscript.connectActive",
286290
"group": "objectscript@1"
287291
},
292+
{
293+
"command": "vscode-objectscript.editOthers",
294+
"when": "resourceScheme == file && editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
295+
"group": "objectscript@2"
296+
},
288297
{
289298
"command": "vscode-objectscript.compile",
290299
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
291-
"group": "objectscript@2"
300+
"group": "objectscript@3"
292301
},
293302
{
294303
"command": "vscode-objectscript.previewXml",
295304
"when": "editorLangId =~ /^xml/",
296-
"group": "objectscript@3"
305+
"group": "objectscript@4"
297306
},
298307
{
299308
"command": "vscode-objectscript.serverCommands.contextSourceControl",
300309
"when": "resourceScheme == isfs && vscode-objectscript.connectActive",
301-
"group": "objectscript@4"
310+
"group": "objectscript@5"
302311
},
303312
{
304313
"command": "vscode-objectscript.serverCommands.contextOther",
305314
"when": "resourceScheme =~ /^isfs(-readonly)?$/ && vscode-objectscript.connectActive",
306-
"group": "objectscript@5"
315+
"group": "objectscript@6"
307316
},
308317
{
309318
"command": "vscode-objectscript.compileOnly",
310319
"when": "editorLangId =~ /^objectscript/ && vscode-objectscript.connectActive",
311-
"group": "objectscript@6"
320+
"group": "objectscript@7"
312321
}
313322
],
314323
"editor/title": [
@@ -637,6 +646,11 @@
637646
"category": "ObjectScript",
638647
"command": "vscode-objectscript.compileOnlyWithFlags",
639648
"title": "Compile Current File with Specified Flags..."
649+
},
650+
{
651+
"category": "ObjectScript",
652+
"command": "vscode-objectscript.editOthers",
653+
"title": "Edit Other"
640654
}
641655
],
642656
"keybindings": [

src/commands/viewOthers.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { config } from "../extension";
44
import { DocumentContentProvider } from "../providers/DocumentContentProvider";
55
import { currentFile } from "../utils";
66

7-
export async function viewOthers(): Promise<void> {
7+
export async function viewOthers(forceEditable = false): Promise<void> {
88
const file = currentFile();
99
if (!file) {
1010
return;
@@ -13,7 +13,7 @@ export async function viewOthers(): Promise<void> {
1313
return;
1414
}
1515

16-
const open = async (item: string) => {
16+
const open = async (item: string, forceEditable: boolean) => {
1717
const colonidx: number = item.indexOf(":");
1818
if (colonidx !== -1) {
1919
// A location is appened to the name of the other document
@@ -22,7 +22,12 @@ export async function viewOthers(): Promise<void> {
2222
// Split the document name form the location
2323
let loc = item.slice(colonidx + 1);
2424
item = item.slice(0, colonidx);
25-
const uri = DocumentContentProvider.getUri(item);
25+
let uri: vscode.Uri;
26+
if (forceEditable) {
27+
uri = DocumentContentProvider.getUri(item, undefined, undefined, forceEditable);
28+
} else {
29+
uri = DocumentContentProvider.getUri(item);
30+
}
2631

2732
if (item.endsWith(".cls")) {
2833
// Locations in classes are of the format method+offset+namespace
@@ -74,7 +79,12 @@ export async function viewOthers(): Promise<void> {
7479
}
7580
vscode.window.showTextDocument(uri, options);
7681
} else {
77-
const uri = DocumentContentProvider.getUri(item);
82+
let uri: vscode.Uri;
83+
if (forceEditable) {
84+
uri = DocumentContentProvider.getUri(item, undefined, undefined, forceEditable);
85+
} else {
86+
uri = DocumentContentProvider.getUri(item);
87+
}
7888
vscode.window.showTextDocument(uri);
7989
}
8090
};
@@ -148,10 +158,10 @@ export async function viewOthers(): Promise<void> {
148158
return;
149159
}
150160
if (listOthers.length === 1) {
151-
open(listOthers[0]);
161+
open(listOthers[0], forceEditable);
152162
} else {
153163
vscode.window.showQuickPick(listOthers).then((item) => {
154-
open(item);
164+
open(item, forceEditable);
155165
});
156166
}
157167
})

src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
775775
});
776776
}),
777777
vscode.commands.registerCommand("vscode-objectscript.jumpToTagAndOffset", jumpToTagAndOffset),
778-
vscode.commands.registerCommand("vscode-objectscript.viewOthers", viewOthers),
778+
vscode.commands.registerCommand("vscode-objectscript.viewOthers", () => viewOthers(false)),
779779
vscode.commands.registerCommand("vscode-objectscript.serverCommands.sourceControl", mainSourceControlMenu),
780780
vscode.commands.registerCommand(
781781
"vscode-objectscript.serverCommands.contextSourceControl",
@@ -786,7 +786,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
786786
vscode.commands.registerCommand("vscode-objectscript.subclass", subclass),
787787
vscode.commands.registerCommand("vscode-objectscript.superclass", superclass),
788788
vscode.commands.registerCommand("vscode-objectscript.serverActions", serverActions),
789-
vscode.commands.registerCommand("vscode-objectscript.touchBar.viewOthers", viewOthers),
789+
vscode.commands.registerCommand("vscode-objectscript.touchBar.viewOthers", () => viewOthers(false)),
790790
vscode.commands.registerCommand("vscode-objectscript.explorer.refresh", () => explorerProvider.refresh()),
791791
// Register the vscode-objectscript.explorer.open command elsewhere
792792
registerExplorerOpen(explorerProvider),
@@ -870,6 +870,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
870870
{ language: "vscode-objectscript-output" },
871871
new DocumentLinkProvider()
872872
),
873+
vscode.commands.registerCommand("vscode-objectscript.editOthers", () => viewOthers(true)),
873874

874875
/* Anything we use from the VS Code proposed API */
875876
...proposed

0 commit comments

Comments
 (0)