Skip to content

Commit

Permalink
## [0.0.5]
Browse files Browse the repository at this point in the history
 Don't jump to beginning when focusing file.
  • Loading branch information
Largo committed Aug 26, 2023
1 parent abcbfd3 commit 7c9bb44
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
All notable changes to the "annotateToggle" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [0.0.5]
- Don't jump to beginning when focusing file.

## [0.0.4]
- Don't fold tabs in the background
Expand All @@ -13,6 +15,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [0.0.2]
- Fold other open tabs too
- Allowing the simultaneous folding of multiple windows. Also make sure the folding works correctly on
startup.
## [0.0.1]

- Initial release
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ annotations used by the ruby on rails annotate gem.

## Requirements



## Extension Settings

This extension contributes the following settings:

* `annotateToggle.annotateTogglesVisible`: Specifies whether the annotateToggles are visible or hidden. Is changed by the the toggle command
* `annotateToggle.autoRunCommand`: Specifies whether the command should be automatically run when a Ruby file is opened.

## Known Issues



## Release Notes

## [0.0.5]
- Don't jump to beginning when focusing file.

### 0.0.2
Allowing the simultaneous folding of multiple windows. Also make sure the folding works correctly on
startup.

### 0.0.1
## [0.0.4]
- Don't fold tabs in the background
- set the toggle status globally instead of per workspace

Initial release of the extension
## [0.0.3]
- Fold and unfold tabs in the background when tabbing

## [0.0.2]
- Fold other open tabs too
- Allowing the simultaneous folding of multiple windows. Also make sure the folding works correctly on
startup.
## [0.0.1]

- Initial release
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
"configuration": {
"type": "object",
"properties": {
"annotateToggle.autoRunCommand": {
"type": "boolean",
"default": true,
"description": "Specifies whether the command should be automatically run when a Ruby file is opened."
},
"annotateToggle.annotateVisible": {
"type": "boolean",
"default": true,
Expand Down
12 changes: 7 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function updateAnnotateTogglesVisibility() {
if (foldingRanges[0]) {
await vscode.window.showTextDocument(editor.document, editor.viewColumn).then(async () => {
if (editor) {
return await toggleFoldingForEditor(editor, isAnnotateVisible);
return await toggleFoldingForEditor(editor, isAnnotateVisible, true);
}
});
}
Expand Down Expand Up @@ -142,7 +142,7 @@ async function foldOrUnfold(editor: vscode.TextEditor, startLine: number, endLin
direction: 'down', // Change this as per requirements
selectionLines: [startLine, endLine] // Apply the fold/unfold action to the start line
};
console.log(command, vscode.window.activeTextEditor?.document?.fileName === editor.document.fileName, editor.document.fileName, args, editor.selection.start, editor.selection.end, editor.selection.anchor.line);
//console.log(command, vscode.window.activeTextEditor?.document?.fileName === editor.document.fileName, editor.document.fileName, args, editor.selection.start, editor.selection.end, editor.selection.anchor.line);
if (vscode.window.activeTextEditor?.document?.fileName === editor.document.fileName) {
return await vscode.commands.executeCommand(command, args);
} else {
Expand All @@ -156,13 +156,15 @@ async function foldOrUnfold(editor: vscode.TextEditor, startLine: number, endLin
return Promise.resolve();
}

async function toggleFoldingForEditor(editor: vscode.TextEditor, isAnnotateVisible: boolean): Promise<unknown> {
async function toggleFoldingForEditor(editor: vscode.TextEditor, isAnnotateVisible: boolean, jumpCursor: boolean): Promise<unknown> {
const foldingRange = getFirstFoldingRange(editor.document);
if (foldingRange) {
const startLine = foldingRange.start;
const endLine = foldingRange.end;

setCursorPosition(editor, startLine);
if(jumpCursor) {
setCursorPosition(editor, startLine);
}
return await foldOrUnfold(editor, startLine, endLine, isAnnotateVisible);
} else {
console.log("no folding range");
Expand Down Expand Up @@ -194,7 +196,7 @@ export async function activate(context: vscode.ExtensionContext) {
const document = editor.document;
if (document.languageId === 'ruby' || document.fileName.endsWith(".rb.git")) {
let isAnnotateVisible = getGlobalAnnotateVisible();
await toggleFoldingForEditor(editor, isAnnotateVisible);
await toggleFoldingForEditor(editor, isAnnotateVisible, false);
}
}
});
Expand Down

0 comments on commit 7c9bb44

Please sign in to comment.