Skip to content

Commit

Permalink
support for ${namespace} in links, solve #99
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Mar 4, 2020
1 parent 63d8364 commit 8cf5581
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/commands/serverActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";
import { config, workspaceState, checkConnection } from "../extension";
import { currentWorkspaceFolder, terminalWithDocker } from "../utils";
import { currentWorkspaceFolder, terminalWithDocker, currentFile } from "../utils";

export async function serverActions(): Promise<void> {
const { active, host, ns, https, port: defaultPort, username, password: defaultPassword, links } = config("conn");
Expand All @@ -19,10 +19,18 @@ export async function serverActions(): Promise<void> {
? `&IRISUsername=${usernameEncoded}&IRISPassword=${passwordEncoded}`
: `&CacheUserName=${usernameEncoded}&CachePassword=${passwordEncoded}`;
const extraLinks = [];
const file = currentFile();
const classname = file && file.name.match(/cls$/i) ? file.name : "";
for (const title in links) {
const link = String(links[title])
let link = String(links[title]);
if (classname == "" && link.includes("${classname}")) {
continue;
}
link = link
.replace("${host}", host)
.replace("${port}", port);
.replace("${port}", port)
.replace("${namespace}", ns == "%SYS" ? "sys" : nsEncoded.toLowerCase())
.replace("${classname}", classname);
extraLinks.push({
id: "extraLink" + extraLinks.length,
label: title,
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export let documentContentProvider: DocumentContentProvider;
export let workspaceState: vscode.Memento;
export let extensionContext: vscode.ExtensionContext;
export let panel: vscode.StatusBarItem;
export let posPanel: vscode.StatusBarItem;
export let terminal: vscode.Terminal;

import TelemetryReporter from "vscode-extension-telemetry";
Expand Down

0 comments on commit 8cf5581

Please sign in to comment.