Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-1278
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano committed Nov 13, 2024
2 parents 7e83e48 + 203c016 commit 31e6063
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [2.12.10] 13-Nov-2024
- Fixes
- Prevent overprompting for permission and account (#1456)

## [2.12.9] 29-Oct-2024
- Enhancements
- Add `Launch Lite Terminal` action to Explorer (#1438)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ To unlock these features (optional):

1. Download and install a beta version from GitHub. This is necessary because Marketplace does not allow publication of extensions that use proposed APIs.
- Go to https://github.com/intersystems-community/vscode-objectscript/releases
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `2.12.9`, look for `2.12.10-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
- Download the VSIX file (for example `vscode-objectscript-2.12.10-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.
- Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `2.12.10`, look for `2.12.11-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs.
- Download the VSIX file (for example `vscode-objectscript-2.12.11-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code.

2. From [Command Palette](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) choose `Preferences: Configure Runtime Arguments`.
3. In the argv.json file that opens, add this line (required for both Stable and Insiders versions of VS Code):
Expand Down
62 changes: 39 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-objectscript",
"displayName": "InterSystems ObjectScript",
"description": "InterSystems ObjectScript language support for Visual Studio Code",
"version": "2.12.10-SNAPSHOT",
"version": "2.12.11-SNAPSHOT",
"icon": "images/logo.png",
"aiKey": "9cd75d51-697c-406c-a929-2bcf46e97c64",
"categories": [
Expand Down Expand Up @@ -48,7 +48,7 @@
}
],
"engines": {
"vscode": "^1.91.0"
"vscode": "^1.93.0"
},
"enabledApiProposals": [
"fileSearchProvider",
Expand Down Expand Up @@ -1777,16 +1777,17 @@
"test": "node ./out/test/runTest.js",
"lint": "eslint src/**",
"lint-fix": "eslint --fix src/**",
"download-api": "dts dev 1.91.0",
"download-api": "dts dev 1.93.0",
"postinstall": "npm run download-api"
},
"devDependencies": {
"@intersystems-community/intersystems-servermanager": "^3.8.0",
"@types/istextorbinary": "2.3.1",
"@types/minimatch": "5.1.2",
"@types/mocha": "^7.0.2",
"@types/node": "20.16.5",
"@types/semver": "7.5.4",
"@types/vscode": "1.91.0",
"@types/vscode": "1.93.0",
"@types/ws": "8.5.4",
"@types/xmldom": "^0.1.29",
"@typescript-eslint/eslint-plugin": "^7.12.0",
Expand Down
21 changes: 15 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const smExtensionId = "intersystems-community.servermanager";

import vscode = require("vscode");
import * as semver from "semver";
import * as serverManager from "@intersystems-community/intersystems-servermanager";

import { AtelierJob, Content, Response, ServerInfo } from "./api/atelier";
export const OBJECTSCRIPT_FILE_SCHEMA = "objectscript";
Expand Down Expand Up @@ -205,7 +206,7 @@ let reporter: TelemetryReporter = null;

export let checkingConnection = false;

let serverManagerApi: any;
let serverManagerApi: serverManager.ServerManagerAPI;

// Map of the intersystems.server connection specs we have resolved via the API to that extension
const resolvedConnSpecs = new Map<string, any>();
Expand All @@ -229,18 +230,26 @@ export async function resolveConnectionSpec(serverName: string): Promise<void> {

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export async function resolvePassword(serverSpec, ignoreUnauthenticated = false): Promise<void> {
const AUTHENTICATION_PROVIDER = "intersystems-server-credentials";
// This arises if setting says to use authentication provider
if (
// Connection isn't unauthenticated
(!isUnauthenticated(serverSpec.username) || ignoreUnauthenticated) &&
// A password is missing
typeof serverSpec.password == "undefined"
) {
const scopes = [serverSpec.name, serverSpec.username || ""];
let session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { silent: true });

// Handle Server Manager extension version < 3.8.0
const account = serverManagerApi.getAccount ? serverManagerApi.getAccount(serverSpec) : undefined;

let session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, {
silent: true,
account,
});
if (!session) {
session = await vscode.authentication.getSession(AUTHENTICATION_PROVIDER, scopes, { createIfNone: true });
session = await vscode.authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, {
createIfNone: true,
account,
});
}
if (session) {
// If original spec lacked username use the one obtained by the authprovider
Expand Down Expand Up @@ -1199,7 +1208,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
}
const fileName = filePathNoWorkspaceArr.join(".");
// Generate the new content
const newContent = generateFileContent(uri, fileName, Buffer.from(await vscode.workspace.fs.readFile(uri)));
const newContent = generateFileContent(uri, fileName, await vscode.workspace.fs.readFile(uri));
// Write the new content to the file
return vscode.workspace.fs.writeFile(uri, new TextEncoder().encode(newContent.content.join("\n")));
})
Expand Down
12 changes: 4 additions & 8 deletions src/providers/FileSystemProvider/FileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Entry = File | Directory;
export function generateFileContent(
uri: vscode.Uri,
fileName: string,
sourceContent: Buffer
sourceContent: Uint8Array
): { content: string[]; enc: boolean } {
const sourceLines = sourceContent.length ? new TextDecoder().decode(sourceContent).split("\n") : [];
const fileExt = fileName.split(".").pop().toLowerCase();
Expand Down Expand Up @@ -107,7 +107,7 @@ export function generateFileContent(
}
}
return {
content: [sourceContent.toString("base64")],
content: [Buffer.from(sourceContent).toString("base64")],
enc: true,
};
}
Expand Down Expand Up @@ -397,7 +397,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {

public writeFile(
uri: vscode.Uri,
content: Buffer,
content: Uint8Array,
options: {
create: boolean;
overwrite: boolean;
Expand Down Expand Up @@ -654,11 +654,7 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
const newCsp = newParams.has("csp") && ["", "1"].includes(newParams.get("csp"));
const newFileName = newCsp ? newUri.path : newUri.path.slice(1).replace(/\//g, ".");
// Generate content for the new file
const newContent = generateFileContent(
newUri,
newFileName,
Buffer.from(await vscode.workspace.fs.readFile(oldUri))
);
const newContent = generateFileContent(newUri, newFileName, await vscode.workspace.fs.readFile(oldUri));
if (newFileStat) {
// We're overwriting an existing file so prompt the user to check it out
await fireOtherStudioAction(OtherStudioAction.AttemptedEdit, newUri);
Expand Down

0 comments on commit 31e6063

Please sign in to comment.