Skip to content

Commit

Permalink
Initial release version
Browse files Browse the repository at this point in the history
  • Loading branch information
mishkinf committed Apr 24, 2018
1 parent 518f7e2 commit 76ef238
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ out
node_modules
.vscode-test/
*.vsix
.DS_Store
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ All notable changes to the "goto-next-member" extension will be documented in th

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [Unreleased]
- Initial release
## [0.0.1] - 2018-04-23

### Added

- Feature to navigate to previous member
- Feature to navigate to next member
58 changes: 15 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,37 @@
# goto-next-member README
# goto-next-previous-member

This is the README for your extension "goto-next-member". After writing up a brief description, we recommend including the following sections.
Visual Studio Code Extenion to navigate through the functions, variables, and classes using quick and easy keycommands similar to functionality provided by IntelliJ IDE's (next/previous function)or Resharper (next/previous member)

## Features

Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
This Extension provides two key commands to navigate up and down through the members in your file.

For example if there is an image subfolder under your extension project workspace:

\!\[feature X\]\(images/feature-x.png\)

> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
\!\[Next Previous Member Demo\]\(demo.gif\)

## Requirements

If you have any requirements or dependencies, add a section describing those and how to install and configure them.
[email protected]+

## Extension Settings

Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.

For example:

This extension contributes the following settings:
This extension contributes the following customizable Keyboard Shortcuts:

* `myExtension.enable`: enable/disable this extension
* `myExtension.thing`: set to `blah` to do something
| Command | Description | Key Command |
| -------------------------------------------- |:------------------------- | :-----------|
| `gotoNextPreviousMember.previousMember` | Move To Previous Member | ctrl+up |
| `gotoNextPreviousMember.nextMember` | Move To Next Member | ctrl+down |

## Known Issues

Calling out known issues can help limit users opening duplicate issues against your extension.
No known issues.

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of ...

### 1.0.1

Fixed issue #.

### 1.1.0

Added features X, Y, and Z.

-----------------------------------------------------------------------------------------------------------

## Working with Markdown

**Note:** You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:

* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux)
* Toggle preview (`Shift+CMD+V` on macOS or `Shift+Ctrl+V` on Windows and Linux)
* Press `Ctrl+Space` (Windows, Linux) or `Cmd+Space` (macOS) to see a list of Markdown snippets
See [CHANGELOG.md](CHANGELOG.md)

### For more information
---------------------------------------------------------------------------------------
### More Visual Studio Code Extenions by `mishkinf`

* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
* [Visual Studio Code Navigate Edits History - Goto Last Edit](https://github.com/mishkinf/vscode-edits-history)

**Enjoy!**
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"name": "goto-next-previous-member",
"displayName": "Go to Next/Previous Member",
"description": "vscode Extenion to navigate through the functions, variables, and classes using quick and easy keycommands similar to functionality provided by IntelliJ IDE's (next/previous function) or Resharper (next/previous member)",
"description": "Visual Studio Code Extenion to navigate through the functions, variables, and classes using quick and easy keycommands similar to functionality provided by IntelliJ IDE's (next/previous function) or Resharper (next/previous member)",
"version": "0.0.1",
"publisher": "mishkinf",
"icon": "logo/icon.png",
"engines": {
"vscode": "^1.22.0"
},
"bugs": {
"url": "https://github.com/mishkinf/vscode-goto-next-previous-member/issues"
},
"homepage": "https://github.com/mishkinf/vscode-goto-next-previous-member",
"repository": {
"type": "git",
"url": "[email protected]:mishkinf/vscode-goto-next-previous-member.git"
},
"categories": [
"Other"
],
Expand Down
61 changes: 31 additions & 30 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,47 @@ export function activate(context: vscode.ExtensionContext) {
)) || [];
};

const activeEditorChangeListener = vscode.window.onDidChangeActiveTextEditor(e => {
dirtyTree = true;
tree = [];
symbolIndex = 0;
});
const documentChangeListener = vscode.workspace.onDidChangeTextDocument(e => {
dirtyTree = true;
tree = [];
symbolIndex = 0;
});

const setSymbolIndex = (currentLine: number, directionNext: boolean) => {
const setSymbolIndex = (cursorLine: number, cursorCharacter: number, directionNext: boolean) => {
let member;

if(directionNext) {
symbolIndex = -1;
do {
symbolIndex++;
} while (tree[symbolIndex] && currentLine > tree[symbolIndex].location.range.start.line);
member = tree[symbolIndex].location.range.start;
} while (member.line < cursorLine || member.line === cursorLine && member.character <= cursorCharacter);

} else {
symbolIndex = tree.length;
do {
symbolIndex--;
} while (tree[symbolIndex] && currentLine <= tree[symbolIndex].location.range.start.line);
member = tree[symbolIndex].location.range.start;
} while (member.line > cursorLine || member.line === cursorLine && member.character >= cursorCharacter);
}
};

const previousMemberCommand = vscode.commands.registerTextEditorCommand("gotoNextPreviousMember.previousMember", async (editor: vscode.TextEditor) => {
let symbol;

if (!tree || dirtyTree) {
refreshTree(editor);
setSymbolIndex(editor.selection.active.line, false);
if (tree.length === 0 || dirtyTree) {
await refreshTree(editor);
dirtyTree = false;
} else {
if (symbolIndex >= 0) {
symbolIndex--;
} else {
symbolIndex = 0;
}
}

const activeCursor = editor.selection.active;
setSymbolIndex(activeCursor.line, activeCursor.character, false);

symbol = tree[symbolIndex];

if (symbol) {
Expand All @@ -56,42 +64,35 @@ export function activate(context: vscode.ExtensionContext) {
symbol.location.range.start.character
);
vscode.commands.executeCommand("revealLine", {
lineNumber: symbol.location.range.start.line,
at: "center"
lineNumber: symbol.location.range.start.line
});
}

console.log("Previous Member");
vscode.window.setStatusBarMessage("Previous Member", 1000);
}
);

const nextMemberCommand = vscode.commands.registerTextEditorCommand("gotoNextPreviousMember.nextMember", async (editor: vscode.TextEditor) => {
let symbol;

if (!tree || dirtyTree) {
refreshTree(editor);
setSymbolIndex(editor.selection.active.line, true);
} else {
if (symbolIndex < tree.length) {
symbolIndex++;
} else {
symbolIndex = tree.length - 1;
}
if (tree.length === 0 || dirtyTree) {
await refreshTree(editor);
dirtyTree = false;
}

const activeCursor = editor.selection.active;
setSymbolIndex(activeCursor.line, activeCursor.character, true);

symbol = tree[symbolIndex];

if (symbol) {
editor.selection = new vscode.Selection(symbol.location.range.start.line, symbol.location.range.start.character, symbol.location.range.start.line, symbol.location.range.start.character);
vscode.commands.executeCommand("revealLine", {
lineNumber: symbol.location.range.start.line,
at: "center"
lineNumber: symbol.location.range.start.line
});
}

console.log("Next Member");
vscode.window.setStatusBarMessage("Next Member", 1000);
}
);

context.subscriptions.push(previousMemberCommand, nextMemberCommand, documentChangeListener);
context.subscriptions.push(previousMemberCommand, nextMemberCommand, documentChangeListener, activeEditorChangeListener);
}

0 comments on commit 76ef238

Please sign in to comment.