Skip to content

Commit

Permalink
Add file context menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Dec 15, 2023
1 parent e058e9f commit 1513ed5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Change Log


## [0.0.3] - 2023-12-15

### Added

- Editor Context Menu.
- Right click to upload a file or selection(s). (Max Size of 30_000 bytes per selection && Max Selections of 5)


## [0.0.2] - 2023-10-25

### Added

- Explorer Right Click Menu.
- Right Click to upload a files contents. (Max Size of 30_000 bytes.)
- Explorer Context Menu.
- Right Click a file in the explorer to upload its contents. (Max Size of 30_000 bytes.)

### Fiexed
- Filename parsing was inaccurate. Added a parser for better results.
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
## Features

- Paste full files or text of any language to MystBin with ``>Share`` (`mystbin.share`).
- Editor and Explorer Context Menus for ease of use. Right Click to send to MystBin.
- Select up to **5** snippets in an open editor and send them to MystBin as separate files.
- Automatically copies the paste URL and has a button to open it in your browser.


## Planned

- Editor Icon/Button for quickly saving a workspace or file.
- Context Menus for quickly pasting files from the explorer or selected text in an editor.
- Fetch and edit existing MystBin pastes via ID or URL.
- Ability to provide your API token for saving pastes to your account.

Expand All @@ -26,10 +26,16 @@
## Release Notes


### 0.0.3

- Added: Editor Context Menu.
- Right click to upload a file or selection(s). (Max Size of 30_000 bytes per selection && Max Selections of 5)


### 0.0.2

- Added: Explorer Right Click Menu.
- Right Click to upload a files contents. (Max Size of 30_000 bytes.)
- Added: Explorer Context Menu.
- Right Click a file in the explorer to upload its contents. (Max Size of 30_000 bytes.)

- Fixed: Filename parsing was inaccurate. Added a parser for better results.

Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mystbin",
"displayName": "MystBin",
"description": "Easily share text and code with mystb.in",
"version": "0.0.2",
"version": "0.0.3",
"license": "SEE LICENSE IN LICENSE",
"publisher": "PythonistaGuild",
"author": {
Expand Down Expand Up @@ -41,6 +41,12 @@
"command": "mystbin.share",
"when": "resourceScheme == file"
}
],
"editor/context": [
{
"command": "mystbin.share",
"when": "editorHasSelection || editorFocus"
}
]
}
},
Expand Down
7 changes: 5 additions & 2 deletions src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ interface PasteContent {


export async function singleEditorUpload(menuResource: vscode.Uri | undefined = undefined) {
let activeEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
let highlighted: FileSelection[];

if (!menuResource) {
let activeEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;

if (!activeEditor) {
vscode.window.showErrorMessage("Please open a file and re-run this command to upload to MystBin. Or Right Click a File in your explorer.");
return;
Expand All @@ -49,6 +48,10 @@ export async function singleEditorUpload(menuResource: vscode.Uri | undefined =
highlighted = getEditorSelections(activeEditor);
}

else if (menuResource.path === activeEditor?.document.uri.path) {
highlighted = getEditorSelections(activeEditor);
}

else {
let fileBytes: Uint8Array = await vscode.workspace.fs.readFile(menuResource);
if (fileBytes.length > MAX_SIZE) {
Expand Down

0 comments on commit 1513ed5

Please sign in to comment.