Skip to content

Commit

Permalink
Merge pull request #31 from mark-wiemer/v2.6.1
Browse files Browse the repository at this point in the history
v2.6.1
  • Loading branch information
mark-wiemer authored Jan 23, 2021
2 parents 37074f8 + a3aa8c6 commit 8e861b2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.6.1 - 2021-01-23

- Fix hover provider ([#16](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/16))

## 2.6.0 - 2021-01-18

### Features
Expand Down
8 changes: 5 additions & 3 deletions docs/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ This document covers the development process, from writing code to publishing a
- Perform the formatting tests
- Confirm README appears as intended
- Confirm links in README work
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. `v-2.5.10`).
- Confirm the package version has been updated
- Confirm the changelog has been updated
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. 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. 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.0",
"version": "2.6.1",
"publisher": "mark-wiemer",
"engines": {
"vscode": "^1.30.0"
Expand Down
23 changes: 13 additions & 10 deletions src/providers/ahkHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ interface Snippet {
}

interface Context {
nextChart: string;
/** The character after the word */
charAfter: string;
word: string;
}

Expand All @@ -35,6 +36,7 @@ export class AhkHoverProvider implements HoverProvider {
token: CancellationToken,
) {
const context = this.buildContext(document, position);
if (context === undefined) return null;

const snippetHover = this.tryGetSnippetHover(context);
if (snippetHover) {
Expand All @@ -43,26 +45,26 @@ export class AhkHoverProvider implements HoverProvider {

const method = await Parser.getMethodByName(document, context.word);
if (method) {
const markdonw = new MarkdownString('', true).appendCodeblock(
const contents = new MarkdownString('', true).appendCodeblock(
method.full,
);
if (method.comment) {
markdonw.appendText(method.comment);
contents.appendText(method.comment);
}
return new Hover(markdonw);
return new Hover(contents);
}

return null;
}

private tryGetSnippetHover(context: Context): Hover {
let snippetKey = context.word.toLowerCase();
if (context.nextChart == '(') {
if (context.charAfter == '(') {
snippetKey += '()';
}
const snippet = this.snippetCache.get(snippetKey);
if (snippet) {
const content = new MarkdownString(null, true).appendCodeblock(
const content = new MarkdownString('', true).appendCodeblock(
snippet.body,
'ahk',
);
Expand All @@ -76,29 +78,30 @@ export class AhkHoverProvider implements HoverProvider {
private buildContext(document: TextDocument, position: Position): Context {
const line = position.line;
const wordRange = document.getWordRangeAtPosition(position);
if (wordRange === undefined) return undefined;
let word = document.getText(wordRange);
if (wordRange.start.character > 0) {
const preChart = document.getText(
const charBefore = document.getText(
new Range(
line,
wordRange.start.character - 1,
line,
wordRange.start.character,
),
);
if (preChart == '#') {
if (charBefore == '#') {
word = '#' + word;
}
}
const nextChart = document.getText(
const charAfter = document.getText(
new Range(
line,
wordRange.end.character,
line,
wordRange.end.character + 1,
),
);
return { word, nextChart };
return { word, charAfter };
}

private initSnippetCache(context: ExtensionContext) {
Expand Down

0 comments on commit 8e861b2

Please sign in to comment.