Skip to content

Commit

Permalink
v2.6.2 (#35)
Browse files Browse the repository at this point in the history
* Update Development.md

* Improve documentation

* Fix #18 (formatting after ternary operator)

* Add newline to end of v1 demo file

* Remove unnecessary comment

* Fix #26 (multiple close braces on one line)

* fixup fix #26

* Add demo README

* Update Development.md

* v2.6.2
  • Loading branch information
mark-wiemer authored Jan 30, 2021
1 parent 8e861b2 commit 0a81383
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 103 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 2.6.2 - 2021-01-30

- Fix formatting after ternary operator ([#18](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/18))
- Fix formatting after multiple close braces on one line ([#26](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/26))

## 2.6.1 - 2021-01-23

- Fix hover provider ([#16](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/16))
Expand Down
3 changes: 3 additions & 0 deletions demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Demos

This folder contains AutoHotkey scripts formatted with this extension.
18 changes: 10 additions & 8 deletions demos/demo_for_ahk_v1.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ function()

obj := { str: str, int: int, float: float }
objobj := { str: str, obj: obj }
; Known bug: the entire body of a function should be indented
; https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/26
objobjobj := { str: str, int: int, obj: { str: str, obj: obj } }
objobjobj := { str: str, int: int, obj: { str: str, obj: obj } }

circular := {}
circular.circular := circular
instance := new Cls()
circular := {}
circular.circular := circular
instance := new Cls()

enum := obj._NewEnum()
enum := obj._NewEnum()
}
class Cls
{
Expand Down Expand Up @@ -103,4 +101,8 @@ ExitApp
f1:: MsgBox, You hit F1

; The F2 hotkey will not work because it was not part of the selection
f2:: MsgBox, You hit F2
f2:: MsgBox, You hit F2

; Formatting line below ternary with third operand a string value
true ? 1 : "string"
foo()
17 changes: 15 additions & 2 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ This document covers the development process, from writing code to publishing a
1. Once the `dev` branch has all the features for a new release, create a new release branch named `v<major>.<minor>.<patch>` (e.g. `v2.5.10`).
1. Update package version
1. Update changelog
1. Save final changes in commit. The message of the commit should be the same name as the branch.
1. Save final changes in commit. The message of the commit should be the name of the release branch.
1. Push the changes, open a PR, review the changes, and merge to `master`.
1. Pull the new master branch
1. Package the new release using `vsce package`.
1. Final round of tests
1. Install new release
1. Perform final round of tests
1. If tests fail, there are two choices:
1. Delay the release until the tests pass (preferred choice)
> Changes can be made on the same release branch, same package version
1. Create issues for the newly-introduced failures before releasing, then publish the release anyway
1. Create and push the version tag
1. Delete the release branch
1. `git tag v<major>.<minor>.<patch>`
1. `git push`
1. Update the metadata in the [Releases Entry](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/releases)
1. Release title: Same as in [CHANGELOG.md](../CHANGELOG.md)
1. Description: Same as in changelog
1. Attach binary
1. Publish the release through [Visual Studio Marketplace](https://marketplace.visualstudio.com/manage/publishers/mark-wiemer)

1. Select the ellipsis `Actions` icon and select `Update`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-autohotkey-plus-plus",
"displayName": "AutoHotkey Plus Plus",
"description": "AutoHotkey IntelliSense, debug, and language support for VS Code, forked from AutoHotkey Plus by cweijan",
"version": "2.6.1",
"version": "2.6.2",
"publisher": "mark-wiemer",
"engines": {
"vscode": "^1.30.0"
Expand Down
23 changes: 14 additions & 9 deletions src/common/codeUtil.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
export class CodeUtil {
/**
* trim unfoucs code.
* @param origin any string
* Trim non-formatted chars out of original lines of code
* @param original Original line of code
*/
public static purity(origin: string): string {
if (!origin) return '';
// TODO: untest
return origin
public static purify(original: string): string {
if (!original) return '';
return original
.replace(/;.+/, '')
.replace(/".*?"/g, '')
.replace(/\{.*?\}/g, '')
.replace(/".*?"/g, '""') // replace string literals with empty string literal
.replace(/{.*}/g, '') // remove matching braces
.replace(/ +/g, ' ')
.replace(/\bgui\b.*/gi, '')
.replace(/\b(msgbox)\b.+?%/gi, '$1');
}

public static join(array: any[], items: any | any[]) {
/**
* Concats an array and an item or array of items. Impure, @see array is modified
* @param array The initial array
* @param items Either an item to add to the end of the array,
* or another array to concat to the end of @see array
*/
public static join(array: unknown[], items: unknown) {
if (array == undefined || items == undefined) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class Parser {
}

private static getLabelByLine(document: vscode.TextDocument, line: number) {
const text = CodeUtil.purity(document.lineAt(line).text);
const text = CodeUtil.purify(document.lineAt(line).text);
const label = /^[ \t]*([\u4e00-\u9fa5_a-zA-Z0-9]+) *:{1}(?!(:|=))/.exec(
text,
);
Expand All @@ -219,7 +219,7 @@ export class Parser {
document: vscode.TextDocument,
line: number,
): Variable | Variable[] {
const lineText = CodeUtil.purity(document.lineAt(line).text);
const lineText = CodeUtil.purify(document.lineAt(line).text);

const defMatch = lineText.match(Parser.varDefPattern);
if (defMatch) {
Expand Down Expand Up @@ -270,7 +270,7 @@ export class Parser {
origin?: string,
) {
origin = origin != undefined ? origin : document.lineAt(line).text;
const text = CodeUtil.purity(origin);
const text = CodeUtil.purify(origin);
const refPattern = /\s*(([\u4e00-\u9fa5_a-zA-Z0-9]+)(?<!if|while)\(.*?\))\s*(\{)?\s*/i;
const methodMatch = text.match(refPattern);
if (!methodMatch) {
Expand Down Expand Up @@ -302,7 +302,7 @@ export class Parser {
);
}
for (let i = line + 1; i < document.lineCount; i++) {
const nextLineText = CodeUtil.purity(document.lineAt(i).text);
const nextLineText = CodeUtil.purify(document.lineAt(i).text);
if (!nextLineText.trim()) {
continue;
}
Expand Down
Loading

0 comments on commit 0a81383

Please sign in to comment.