Skip to content

Commit

Permalink
minor(1.7.0): add collapse command feature (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunSHamilton authored Oct 24, 2022
1 parent 7f7c6af commit 5175665
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Released]

##[1.7.0](#v1.7.0) (2022-10-24)

### Added

- `freeCodeCamp: Collapse` command to collapse all matched text levels in the editor

##[1.6.1](#v1.6.1) (2022-10-22)

### Updated
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "freecodecamp-courses",
"displayName": "freeCodeCamp - Courses",
"description": "Provides tooling for quick and easy selection of courses offered by freeCodeCamp",
"version": "1.6.1",
"version": "1.7.0",
"author": "freeCodeCamp",
"publisher": "freeCodeCamp",
"galleryBanner": {
Expand All @@ -28,6 +28,7 @@
"onCommand:freecodecamp-courses.createNewCourse",
"onCommand:freecodecamp-courses.runCourse",
"onCommand:freecodecamp-courses.developCourse",
"onCommand:freecodecamp-courses.collapse",
"onCommand:freecodecamp-courses.test"
],
"main": "./dist/extension.js",
Expand All @@ -49,6 +50,10 @@
"command": "freecodecamp-courses.developCourse",
"title": "freeCodeCamp: Develop Course"
},
{
"command": "freecodecamp-courses.collapse",
"title": "freeCodeCamp: Collapse"
},
{
"command": "freecodecamp-courses.shutdownCourse",
"title": "freeCodeCamp: Shutdown Course"
Expand Down
21 changes: 21 additions & 0 deletions src/commands/collapse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { window, commands } from "vscode";

export default async function collapse() {
const editor = window.activeTextEditor;
if (!editor) {
return;
}
const selections = editor.selections;
try {
await commands.executeCommand("editor.action.selectHighlights");
} catch (e) {
console.error("freeCodeCamp Courses: ", e);
}
selections.forEach(async (selection) => {
try {
await commands.executeCommand("editor.fold", selection.start);
} catch (e) {
console.error("freeCodeCamp Courses: ", e);
}
});
}
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import openCourse from "./commands/open-course";
import runCourse from "./commands/run-course";
import developCourse from "./commands/develop-course";
import createNewCourse from "./commands/create-new-course";
import collapse from "./commands/collapse";
import test from "./commands/test";

export function activate(context: ExtensionContext) {
Expand All @@ -23,6 +24,11 @@ export function activate(context: ExtensionContext) {
developCourse();
})
);
context.subscriptions.push(
commands.registerCommand("freecodecamp-courses.collapse", async () => {
collapse();
})
);
context.subscriptions.push(
commands.registerCommand(
"freecodecamp-courses.shutdownCourse",
Expand Down

0 comments on commit 5175665

Please sign in to comment.