Skip to content

Commit

Permalink
Merge branch 'master' into feature/connection-browser-enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjorgensen authored Feb 16, 2024
2 parents 1642a36 + bef403a commit 0295f5d
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ jobs:
repo: context.repo.repo,
body: '👋 A new build is available for this PR based on ${{ github.event.pull_request.head.sha }}.\n * [Download here.](https://github.com/codefori/vscode-ibmi/actions/runs/${{ github.run_id }})\n* [Read more about how to test](https://github.com/codefori/vscode-ibmi/blob/master/.github/pr_testing_template.md)'
})
- name: Build types
run: npm run typings
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

<img src="./icon.png" align="right">

Maintain your RPGLE, CL, COBOL, C/CPP on IBM i right from Visual Studio Code. Edit and compile all ILE languages, view errors inline, content assist for RPGLE and CL, source date support, and much more. Code for IBM i has hundreds of daily users and over 6000 downloads. We strive on being open-source so we can best support our community.
Maintain your RPGLE, CL, COBOL, C/CPP on IBM i right from Visual Studio Code. Edit and compile all ILE languages, view errors inline, content assist for RPGLE and CL, source date support, and much more. Code for IBM i has thousands of daily users and a rapidly increasing number of downloads. We embrace open-source so that we can best support our community.

* [Install from Marketplace](https://marketplace.visualstudio.com/items?itemName=HalcyonTechLtd.code-for-ibmi) 💻
* [Install the extension pack](https://marketplace.visualstudio.com/items?itemName=HalcyonTechLtd.ibm-i-development-pack) for RPGLE, CL and COBOL support 📦
* [Watch some tutorials](https://www.youtube.com/playlist?list=PLNl31cqBafCp-ml8WqPeriHWLD1bkg7KL) 📺
* [View our documentation](https://codefori.github.io/docs/#/) 📘
* [See previous releases](https://github.com/codefori/vscode-ibmi/releases) 🔎
Expand Down
88 changes: 50 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"icon": "icon.png",
"displayName": "Code for IBM i",
"description": "Maintain your RPGLE, CL, COBOL, C/CPP on IBM i right from Visual Studio Code.",
"version": "2.6.7-dev.0",
"version": "2.7.0",
"keywords": [
"ibmi",
"rpgle",
Expand Down Expand Up @@ -369,6 +369,11 @@
"default": false,
"description": "Show description of libraries in User Library List (recommended to also enable SQL)."
},
"showHiddenFiles": {
"type": "boolean",
"default": true,
"description": "Show hidden files and directories in IFS browser."
},
"debugPort": {
"type": "string",
"default": "8005",
Expand Down Expand Up @@ -1255,20 +1260,20 @@
{
"command": "code-for-ibmi.refreshIFSBrowser",
"enablement": "code-for-ibmi:connected",
"title": "Refresh",
"title": "Refresh IFS List",
"category": "IBM i",
"icon": "$(refresh)"
},
{
"command": "code-for-ibmi.refreshIFSBrowserItem",
"enablement": "code-for-ibmi:connected",
"title": "Refresh List item",
"title": "Refresh IFS List item",
"category": "IBM i"
},
{
"command": "code-for-ibmi.revealInIFSBrowser",
"enablement": "code-for-ibmi:connected",
"title": "Reveal Browser Item",
"title": "Reveal IFS Browser Item",
"category": "IBM i"
},
{
Expand All @@ -1281,7 +1286,7 @@
{
"command": "code-for-ibmi.deleteIFS",
"enablement": "code-for-ibmi:connected",
"title": "Delete",
"title": "Delete Object",
"category": "IBM i"
},
{
Expand All @@ -1293,7 +1298,7 @@
{
"command": "code-for-ibmi.moveIFS",
"enablement": "code-for-ibmi:connected",
"title": "Rename/Move",
"title": "Rename or Move Object",
"category": "IBM i",
"icon": "$(files)"
},
Expand All @@ -1307,21 +1312,21 @@
{
"command": "code-for-ibmi.searchIFS",
"enablement": "code-for-ibmi:connected",
"title": "Search",
"title": "Search Directory",
"category": "IBM i",
"icon": "$(search)"
},
{
"command": "code-for-ibmi.createDirectory",
"enablement": "code-for-ibmi:connected",
"title": "New Directory",
"title": "Create Directory",
"category": "IBM i",
"icon": "$(new-folder)"
},
{
"command": "code-for-ibmi.createStreamfile",
"enablement": "code-for-ibmi:connected",
"title": "New File",
"title": "Create Streamfile",
"category": "IBM i",
"icon": "$(new-file)"
},
Expand Down Expand Up @@ -1355,49 +1360,49 @@
{
"command": "code-for-ibmi.addIFSShortcut",
"enablement": "code-for-ibmi:connected",
"title": "Add Shortcut",
"title": "Add IFS Shortcut",
"category": "IBM i",
"icon": "$(add)"
},
{
"command": "code-for-ibmi.removeIFSShortcut",
"enablement": "code-for-ibmi:connected",
"title": "Remove Shortcut",
"title": "Remove IFS Shortcut",
"category": "IBM i",
"icon": "$(remove)"
},
{
"command": "code-for-ibmi.sortIFSShortcuts",
"enablement": "code-for-ibmi:connected",
"title": "Sort Shortcuts",
"title": "Sort IFS Shortcuts",
"category": "IBM i",
"icon": "$(list-ordered)"
},
{
"command": "code-for-ibmi.moveIFSShortcutDown",
"enablement": "code-for-ibmi:connected",
"title": "Move Shortcut Down",
"title": "Move IFS Shortcut Down",
"category": "IBM i",
"icon": "$(arrow-down)"
},
{
"command": "code-for-ibmi.moveIFSShortcutUp",
"enablement": "code-for-ibmi:connected",
"title": "Move Shortcut Up",
"title": "Move IFS Shortcut Up",
"category": "IBM i",
"icon": "$(arrow-up)"
},
{
"command": "code-for-ibmi.moveIFSShortcutToTop",
"enablement": "code-for-ibmi:connected",
"title": "Move Shortcut to Top",
"title": "Move IFS Shortcut to Top",
"category": "IBM i",
"icon": "$(arrow-up)"
},
{
"command": "code-for-ibmi.moveIFSShortcutToBottom",
"enablement": "code-for-ibmi:connected",
"title": "Move Shortcut to Bottom",
"title": "Move IFS Shortcut to Bottom",
"category": "IBM i",
"icon": "$(arrow-up)"
},
Expand Down Expand Up @@ -1474,7 +1479,7 @@
{
"command": "code-for-ibmi.refreshObjectBrowser",
"enablement": "code-for-ibmi:connected",
"title": "Refresh",
"title": "Refresh Object Browser",
"category": "IBM i",
"icon": "$(refresh)"
},
Expand Down Expand Up @@ -1580,7 +1585,7 @@
},
{
"command": "code-for-ibmi.openTerminalHere",
"title": "Open Terminal Here",
"title": "Open terminal here",
"category": "IBM i"
},
{
Expand All @@ -1599,6 +1604,13 @@
"title": "Edit",
"enablement": "code-for-ibmi:connected",
"category": "IBM i"
},
{
"command": "code-for-ibmi.ifs.toggleShowHiddenFiles",
"title": "Toggle hidden files",
"enablement": "code-for-ibmi:connected",
"category": "IBM i",
"icon": "$(shield)"
}
],
"keybindings": [
Expand Down Expand Up @@ -2093,7 +2105,7 @@
"when": "view == ifsBrowser"
},
{
"command": "code-for-ibmi.removeIFSShortcut",
"command": "code-for-ibmi.ifs.toggleShowHiddenFiles",
"group": "navigation",
"when": "view == ifsBrowser"
},
Expand Down Expand Up @@ -2382,35 +2394,35 @@
"group": "1_workspace@1"
},
{
"command": "code-for-ibmi.createStreamfile",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^directory.*$/",
"group": "2_ifsStuff@1"
"command": "code-for-ibmi.deleteIFS",
"when": "view == ifsBrowser && !(viewItem =~ /^.*_protected$/)",
"group": "2_ifsStuff@4"
},
{
"command": "code-for-ibmi.createDirectory",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^directory.*$/",
"command": "code-for-ibmi.moveIFS",
"when": "view == ifsBrowser && !listMultiSelection && !(viewItem =~ /^.*_protected$/)",
"group": "2_ifsStuff@2"
},
{
"command": "code-for-ibmi.copyIFS",
"when": "view == ifsBrowser && !listMultiSelection && !(viewItem =~ /^.*_protected$/)",
"group": "2_ifsStuff@3"
},
{
"command": "code-for-ibmi.moveIFS",
"when": "view == ifsBrowser && !listMultiSelection && !(viewItem =~ /^.*_protected$/)",
"group": "2_ifsStuff@4"
"group": "2_ifsStuff@2"
},
{
"command": "code-for-ibmi.deleteIFS",
"when": "view == ifsBrowser && !(viewItem =~ /^.*_protected$/)",
"group": "2_ifsStuff@5"
"command": "code-for-ibmi.createDirectory",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^directory.*$/",
"group": "2_ifsStuff@2"
},
{
"submenu": "code-for-ibmi.sortIFSFiles",
"when": "view == ifsBrowser && !listMultiSelection",
"group": "5_ifsStuff@1"
},
{
"command": "code-for-ibmi.createStreamfile",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^directory.*$/",
"group": "2_ifsStuff@1"
},
{
"command": "code-for-ibmi.searchIFS",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^directory.*$/",
Expand All @@ -2427,14 +2439,14 @@
"group": "3_ifsStuff@3"
},
{
"command": "code-for-ibmi.createStreamfile",
"command": "code-for-ibmi.createDirectory",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^shortcut.*$/",
"group": "2_ifsStuff@1"
"group": "2_ifsStuff@2"
},
{
"command": "code-for-ibmi.createDirectory",
"command": "code-for-ibmi.createStreamfile",
"when": "view == ifsBrowser && !listMultiSelection && viewItem =~ /^shortcut.*$/",
"group": "2_ifsStuff@2"
"group": "2_ifsStuff@1"
},
{
"command": "code-for-ibmi.searchIFS",
Expand Down Expand Up @@ -2552,7 +2564,7 @@
"vscode:prepublish": "webpack --mode production",
"webpack": "webpack --mode development",
"webpack-dev": "webpack --mode development --watch",
"typings": "npx -p typescript tsc ./src/extension.ts --declaration --allowJs --emitDeclarationOnly --outDir types --esModuleInterop -t es2021 --moduleResolution node"
"typings": "npx -p typescript tsc ./src/extension.ts --declaration --allowJs --emitDeclarationOnly --outDir types --esModuleInterop -t es2022 --moduleResolution node"
},
"devDependencies": {
"@types/glob": "^7.1.3",
Expand Down
4 changes: 3 additions & 1 deletion src/api/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export namespace ConnectionConfiguration {
quickConnect: boolean;
defaultDeploymentMethod: DeploymentMethod | '';
protectedPaths: string[];
showHiddenFiles: boolean;
[name: string]: any;
}

Expand Down Expand Up @@ -140,7 +141,8 @@ export namespace ConnectionConfiguration {
readOnlyMode: (parameters.readOnlyMode === true),
quickConnect: (parameters.quickConnect === true || parameters.quickConnect === undefined),
defaultDeploymentMethod: parameters.defaultDeploymentMethod || ``,
protectedPaths: (parameters.protectedPaths || [])
protectedPaths: (parameters.protectedPaths || []),
showHiddenFiles: (parameters.showHiddenFiles === true || parameters.showHiddenFiles === undefined),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export default class IBMiContent {
* @param member Will default to file provided
* @param deleteTable Will delete the table after download
*/
async getTable(library: string, file: string, member: string, deleteTable?: boolean): Promise<Tools.DB2Row[]> {
async getTable(library: string, file: string, member?: string, deleteTable?: boolean): Promise<Tools.DB2Row[]> {
if (!member) member = file; //Incase mbr is the same file

if (file === member && this.config.enableSQL) {
Expand Down
21 changes: 21 additions & 0 deletions src/api/Tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,27 @@ export namespace Tools {
}
}


/**
* We do this to find previously opened files with the same path, but different case OR readonly flags.
* Without this, it's possible for the same document to be opened twice simply due to the readonly flag.
*/
export function findExistingDocumentUri(uri: vscode.Uri) {
const baseUriString = uriStringWithoutFragment(uri);
const possibleDoc = vscode.workspace.textDocuments.find(document => uriStringWithoutFragment(document.uri) === baseUriString);
return possibleDoc?.uri || uri;
}

/**
* We convert member to lowercase as members are case insensitive.
*/
function uriStringWithoutFragment(uri: vscode.Uri) {
// To lowercase because the URI path is case-insensitive
const baseUri = uri.scheme + `:` + uri.path;
const isCaseSensitive = (uri.scheme === `streamfile` && /^\/QOpenSys\//i.test(uri.path));
return (isCaseSensitive ? baseUri : baseUri.toLowerCase());
}

/**
* Fixes an SQL statement to make it compatible with db2 CLI program QZDFMDB2.
* - Changes `@clCommand` statements into Call `QSYS2.QCMDEX('clCommand')` procedure calls
Expand Down
5 changes: 3 additions & 2 deletions src/api/errors/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { parseErrors } from "./parser";
import { FileError } from "../../typings";
import { getEvfeventFiles } from "../local/actions";
import { GlobalConfiguration } from "../Configuration";
import { Tools } from "../Tools";

const ileDiagnostics = vscode.languages.createDiagnosticCollection(`ILE`);

Expand Down Expand Up @@ -168,9 +169,9 @@ export async function handleEvfeventLines(lines: string[], instance: Instance, e
}
} else {
if (file.startsWith(`/`))
ileDiagnostics.set(vscode.Uri.from({ scheme: `streamfile`, path: file }), diagnostics);
ileDiagnostics.set(Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `streamfile`, path: file })), diagnostics);
else {
const memberUri = vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` });
const memberUri = Tools.findExistingDocumentUri(vscode.Uri.from({ scheme: `member`, path: `/${asp}${file}${evfeventInfo.extension ? `.` + evfeventInfo.extension : ``}` }));
ileDiagnostics.set(memberUri, diagnostics);
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/instantiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Instance from "./api/Instance";
import { Search } from "./api/Search";
import { Terminal } from './api/Terminal';
import { refreshDiagnosticsFromServer } from './api/errors/diagnostics';
import { QSysFS, getUriFromPath } from "./filesystems/qsys/QSysFs";
import { QSysFS, getUriFromPath, parseFSOptions } from "./filesystems/qsys/QSysFs";
import { init as clApiInit } from "./languages/clle/clApi";
import * as clRunner from "./languages/clle/clRunner";
import { initGetNewLibl } from "./languages/clle/getnewlibl";
Expand Down Expand Up @@ -120,6 +120,18 @@ export async function loadAllofExtension(context: vscode.ExtensionContext) {
}

const uri = getUriFromPath(path, options);

const existingUri = Tools.findExistingDocumentUri(uri);

if (existingUri) {
const existingOptions = parseFSOptions(existingUri);
if (existingOptions.readonly !== options.readonly) {
vscode.window.showWarningMessage(`The file is already opened in another mode.`);
vscode.window.showTextDocument(existingUri);
return false;
}
}

try {
await vscode.commands.executeCommand(`vscode.openWith`, uri, 'default', { selection: options.position } as vscode.TextDocumentShowOptions);

Expand Down
Loading

0 comments on commit 0295f5d

Please sign in to comment.