Skip to content

Commit

Permalink
v2.0.0 - Upgrade the "active" commands to operate
Browse files Browse the repository at this point in the history
on any file.
  • Loading branch information
robole committed Dec 12, 2023
1 parent 6ae9da0 commit 915b40d
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 226 deletions.
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/-0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2023-12-12

## Changed

- Upgraded **minimum version of VS Code to support extension to 1.84** i.e. the `engines` field in `package.json`. I want to avail of the most recent API to improve the extension.
- Change the commands: `File Bunny: Open Active File in External Default App`, `File Bunny: Move Active File`, `File Bunny: Rename Active File`, `File Bunny: Duplicate Active File`, `File Bunny: Delete Active File`, and `File Bunny: Copy File Name` to be able to operate on any type of file. It was limited to text files. Uses the [`Tabgroup`](https://code.visualstudio.com/api/references/vscode-api#TabGroup) and [`Tab`](https://code.visualstudio.com/api/references/vscode-api#Tab) interfaces.
- Changed `File Bunny: Delete File` to delete the file and not close any open tabs related to that deleted file.
- Organised functions in *fileAction.js* to correspond with README for easier cross-referencing. Added region comments to each major section.

## Removed

- Removed "new" image label from `Filebunny: Starting Location Open Folder` in README.

## [1.10.2] - 2023-12-12

## Fixed
### Fixed

- Fixed spacing in lists in README that affected layout.

## [1.10.1] - 2023-12-12

## Fixed
### Fixed

- Fixed typo in README in commands section. Accidentally deleted `File Bunny: Open File` title from list! Doh!

Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">
<br>
<img align="center" src="img/logo.png" width="200">
<img align="center" alt="File Bunny logo. It is a bunny inside a filing cabinet with its head popped up between files" src="img/logo.png" width="200">
<br>
<br>
File Bunny
Expand All @@ -12,7 +12,7 @@
<p align="center">
<img src="https://img.shields.io/static/v1?logo=visual-studio-code&label=made%20for&message=VS%20Code&color=blue" alt="Made for VSCode">
<img src="https://img.shields.io/visual-studio-marketplace/v/robole.file-bunny?logo=visual-studio-code&color=blue" alt="Visual Studio Marketplace Version">
<img src="https://img.shields.io/static/v1?logo=visual-studio-code&label=size&message=60KB&color=blue"
<img src="https://img.shields.io/static/v1?logo=visual-studio-code&label=size&message=61KB&color=blue"
alt="Extension file size in bytes">
<img src="https://img.shields.io/visual-studio-marketplace/r/robole.file-bunny?logo=visual-studio-code&color=blue" alt="Visual Studio Marketplace Rating">
<img src="https://img.shields.io/visual-studio-marketplace/d/robole.file-bunny?logo=visual-studio-code&color=blue" alt="downloads"/>
Expand Down Expand Up @@ -75,13 +75,15 @@ There are times when you want to do something with a workspace file outside of V

You may want to perform some action on a group of files, so it's probably easier to open that folder in your system file manager and do it there. You can use the `File Bunny: Open Workspace Folder Externally` command, or the `File Bunny: Open Folder Externally` command to open a specific folder.

You may want to edit a file in an app specific to that file type. I often want to edit SVG images in my default editor (Inkscape). You can use the `File Bunny: Open File in External App` command to do this.
You may want to edit a file in an app specific to that file type. For example, I often want to edit SVG files in *Inkscape*, my preferred vector graphics editor. You can use the `File Bunny: Open File in External App` command to do this.

## Commands

The following commands can be run from the Command Palette (`Ctrl+Shift+P`). They are categorised below:

### File actions
### File Actions

These commands are scoped to the active workspace.

1. `File Bunny: Open File`: Choose a file to open from the current workspace.
1. `File Bunny: Open File to the Right`: Choose a file to open from the current workspace, and split it to the right of the active editor.
Expand All @@ -99,22 +101,24 @@ The following commands can be run from the Command Palette (`Ctrl+Shift+P`). The
1. `File Bunny: Open Active File in External Default App`: Open the active file in the system default app.
1. `File Bunny: Move Active File`: Move the active file to another location in the current workspace.
1. `File Bunny: Duplicate Active File`: Copy the active file and place it somewhere in the current workspace.
1. `File Bunny: Rename Active File`
1. `File Bunny: Rename Active File`: Change the name of the active file.
1. `File Bunny: Delete Active File`: Delete the active file. The file is put into the trash (recycle bin).

### Folder actions

These commands are scoped to the active workspace.

1. `File Bunny: Open Folder`: Choose a folder to open as the workspace.
1. `File Bunny: Open Workspace Folder in External Default App`: Open the current workspace folder in the Operating Systems' file explorer.
1. `File Bunny: Open Folder in External Default App`: Open a folder from the current workspace in the Operating Systems' file explorer.
1. `File Bunny: Open Workspace Folder in External Default App`: Open the current workspace folder in the system file explorer.
1. `File Bunny: Open Folder in External Default App`: Open a folder from the current workspace in the system file explorer.
1. `File Bunny: Create New Folder`: Create a new folder in the current workspace.
1. `File Bunny: Duplicate Folder`: Duplicate a folder from the current workspace, and place it somewhere in the current workspace.
1. `File Bunny: Delete Folder`: Delete a folder from the current workspace.

### Quick navigation

1. `File Bunny: Go to Top of Active File`
1. `File Bunny: Go to End of Active File`
1. `File Bunny: Go to Top of Active File`: Takes you to the first line of a file.
1. `File Bunny: Go to End of Active File`: Takes you to the last line of a file.

### Quick metadata

Expand All @@ -125,7 +129,7 @@ The following commands can be run from the Command Palette (`Ctrl+Shift+P`). The
## Settings

- `Filebunny: Excludes`: Configure glob patterns for excluding files and folders from file lists for commands. By default, the *.git* and *node_modules* folders are ignored in your workspace.
- `Filebunny: Starting Location Open Folder`: The initial location shown in the QuickPick when you run the command `File Bunny: Open Folder`. If this field is empty or the path is invalid, it will default to the system home directory. ![New command](/img/new.png)
- `Filebunny: Starting Location Open Folder`: The initial location shown in the QuickPick when you run the command `File Bunny: Open Folder`. If this field is empty or the path is invalid, it will default to the system home directory.

## Keybindings

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
},
"description": "Perform file actions quickly with keyboard-driven file selection. 🐰⌨️",
"icon": "img/logo.png",
"version": "1.10.2",
"version": "2.0.0",
"engines": {
"vscode": "^1.46.0",
"vscode": "^1.84.0",
"node": ">=12"
},
"categories": [
Expand Down Expand Up @@ -279,7 +279,7 @@
"@types/glob": "^7.1.3",
"@types/mocha": "^8.0.4",
"@types/node": "^12.11.7",
"@types/vscode": "^1.46.0",
"@types/vscode": "^1.84.0",
"@vscode/test-electron": "^2.3.0",
"@vscode/vsce": "^2.22.0",
"chai": "^4.3.4",
Expand Down
45 changes: 24 additions & 21 deletions src/duplicateActiveFilePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,35 @@ class DuplicateActiveFilePicker extends MultiStepPicker {

super(steps);

this.fileName = nodePath.basename(
vscode.window.activeTextEditor.document.fileName
);

this.steps[1].value = this.fileName;

if (util.isWorkspaceOpen()) {
if (util.isWorkspaceOpen() === false) {
this.close();
throw new Error(
"You cannot duplicate a file if there is no open workspace."
);
} else {
this.rootFolder = vscode.workspace.workspaceFolders[0].uri.fsPath;
}

if (util.hasActiveTab()) {
this.activeFileUri = util.getActiveTabUri();
if (this.activeFileUri) {
this.filename = nodePath.basename(this.activeFileUri.fsPath);
}
} else {
this.close();
throw new Error("There is no active file");
}

this.steps[1].value = this.filename;

let disposable1 = this.picker.onDidChangeValue(
this.onDidChangeValue.bind(this)
);
this.disposables.push(disposable1);
}

async run() {
if (vscode.window.activeTextEditor === undefined) {
return;
}

if (this.rootFolder === undefined) {
vscode.window.showWarningMessage(
"You cannot duplicate a file if a workspace is not open."
);
this.close();
if (util.isWorkspaceOpen() === false || util.isWorkspaceOpen() === false) {
return;
}

Expand Down Expand Up @@ -86,8 +89,8 @@ class DuplicateActiveFilePicker extends MultiStepPicker {

this.currentStepNum = 2;
this.steps[1].title = `Duplicate Active File - name - '${
this.fileName
}' to '${nodePath.join(selection, this.fileName)}'`;
this.filename
}' to '${nodePath.join(selection, this.filename)}'`;
this.setCurrentStep(this.steps[1]);
} else if (this.currentStepNum === 2) {
this.steps[1].value = currentValue;
Expand Down Expand Up @@ -122,7 +125,7 @@ class DuplicateActiveFilePicker extends MultiStepPicker {
}

setTitle(filepath) {
this.picker.title = `Duplicate Active File - name - '${this.fileName}' to '${filepath}'`;
this.picker.title = `Duplicate Active File - name - '${this.filename}' to '${filepath}'`;
}

async duplicateFile() {
Expand All @@ -131,14 +134,14 @@ class DuplicateActiveFilePicker extends MultiStepPicker {
this.steps[0].value,
this.steps[1].value
);
let activeDocUri = vscode.window.activeTextEditor.document.uri;

let newUri = vscode.Uri.file(absoluteFilepath);

try {
let exists = await fileSystem.exists(newUri);

if (exists === false) {
await vscode.workspace.fs.copy(activeDocUri, newUri, {
await vscode.workspace.fs.copy(this.activeFileUri, newUri, {
overwrite: false,
});
await vscode.commands.executeCommand("vscode.open", newUri);
Expand Down
Loading

0 comments on commit 915b40d

Please sign in to comment.