Skip to content

Commit

Permalink
Version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptibell committed Dec 31, 2023
1 parent 62c036b commit 1d758e7
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 54 deletions.
19 changes: 15 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## `0.2.1` - December 31st, 2023

### Added

- Added a VSCode extension command to manually set a GitHub Personal Access Token.
If you are using a private Wally registry and the index repository is not public, you will need to set this for the extension to work.

### Fixed

- Fixed crash when encountering empty TOML sections

## `0.2.0` - October 30th, 2023

### Added
Expand All @@ -19,14 +30,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed invalid diagnostics for wally dev dependencies
- Fixed invalid diagnostics for Wally dev dependencies

## `0.1.0` - September 26th, 2023

### Added

- Added diagnostics for unsupported operating system and/or architecture (aftman)
- Added diagnostics for invalid dependency realms (wally)
- Added diagnostics for unsupported operating system and/or architecture (Aftman)
- Added diagnostics for invalid dependency realms (Wally)

### Changed

Expand Down Expand Up @@ -54,7 +65,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed crash for wally manifests with empty dependency sections:
- Fixed crash for Wally manifests with empty dependency sections:

```toml
# No longer crashes
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tooling-language-server"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "A language server for tooling"
keywords = ["lsp", "language-server", "tower"]
Expand Down
4 changes: 2 additions & 2 deletions editors/vscode/package-lock.json

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

6 changes: 5 additions & 1 deletion editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tooling-language-server",
"displayName": "Tooling Language Server",
"description": "A language server for tooling",
"version": "0.2.0",
"version": "0.2.1",
"license": "MPL-2.0",
"publisher": "filiptibell",
"author": {
Expand Down Expand Up @@ -38,6 +38,10 @@
}
],
"commands": [
{
"command": "tooling-language-server.promptAuthForGitHub",
"title": "Tooling Language Server - Add GitHub Personal Access Token"
},
{
"command": "tooling-language-server.resetAuthForGitHub",
"title": "Tooling Language Server - Reset GitHub Personal Access Token"
Expand Down
61 changes: 33 additions & 28 deletions editors/vscode/src/auth/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,43 @@ const validate = async (token: string): Promise<boolean> => {
Any token returned from this function is guaranteed to currently be valid.
*/
export const prompt = async (): Promise<string | null> => {
export const prompt = async (
skipNotification?: true
): Promise<string | null> => {
const context = getExtensionContext();

const result = await vscode.window.showInformationMessage(
"The GitHub API rate limit has been reached." +
"\nSome functionality will be disabled until authenticated.",
"Set Personal Access Token"
);

if (result === "Set Personal Access Token") {
let prompt = "Enter a token";
while (true) {
const token = await vscode.window.showInputBox({
prompt,
title: "GitHub Personal Access Token",
password: true,
ignoreFocusOut: true,
});
if (token !== undefined) {
if (token !== "" && (await validate(token))) {
await context.globalState.update(
GITHUB_AUTH_TOKEN_STORAGE_KEY,
token
);
return token;
} else {
prompt = "Token is not valid. Enter a new token";
continue;
}
if (skipNotification !== true) {
const result = await vscode.window.showInformationMessage(
"The GitHub API rate limit has been reached." +
"\nSome functionality will be disabled until authenticated.",
"Set Personal Access Token"
);
if (result !== "Set Personal Access Token") {
return null;
}
}

let prompt = "Enter a token";
while (true) {
const token = await vscode.window.showInputBox({
prompt,
title: "GitHub Personal Access Token",
password: true,
ignoreFocusOut: true,
});
if (token !== undefined) {
if (token !== "" && (await validate(token))) {
await context.globalState.update(
GITHUB_AUTH_TOKEN_STORAGE_KEY,
token
);
return token;
} else {
break;
prompt = "Token is not valid. Enter a new token";
continue;
}
} else {
break;
}
}

Expand Down
6 changes: 6 additions & 0 deletions editors/vscode/src/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import * as client from "../client";

import auth from "../auth";

export const promptAuthForGitHub = async (args: {}) => {
await auth.github.prompt(true);
await client.restartServer();
};

export const resetAuthForGitHub = async (args: {}) => {
await auth.github.reset();
await client.restartServer();
};

export default {
promptAuthForGitHub,
resetAuthForGitHub,
};
14 changes: 5 additions & 9 deletions src/lang/toml/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ impl TomlArray {
match node.as_array() {
None => None,
Some(array) => {
let mut range_first = None;
let mut range_last = None;
// NOTE: Node is guaranteed to have at least one text range
let mut text_range = node.text_ranges().next().unwrap();
for range in node.text_ranges() {
if range_first.is_none() {
range_first = Some(range)
} else {
range_last = Some(range)
}
text_range = text_range.cover(range);
}

let span = Range {
start: u32::from(range_first.unwrap().start()) as usize,
end: u32::from(range_last.unwrap().end()) as usize,
start: u32::from(text_range.start()) as usize,
end: u32::from(text_range.end()) as usize,
};

let source = source.as_ref();
Expand Down
13 changes: 5 additions & 8 deletions src/lang/toml/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@ impl TomlTable {
match node.as_table() {
None => None,
Some(table) => {
let mut range_first = None;
let mut range_last = None;
// NOTE: Node is guaranteed to have at least one text range
let mut text_range = node.text_ranges().next().unwrap();
for range in node.text_ranges() {
if range_first.is_none() {
range_first = Some(range)
}
range_last = Some(range)
text_range = text_range.cover(range);
}

let span = Range {
start: u32::from(range_first?.start()) as usize,
end: u32::from(range_last?.end()) as usize,
start: u32::from(text_range.start()) as usize,
end: u32::from(text_range.end()) as usize,
};

let source = source.as_ref();
Expand Down

0 comments on commit 1d758e7

Please sign in to comment.