Skip to content

Commit

Permalink
Merge pull request #3 from nkosakul/release/1.1.0
Browse files Browse the repository at this point in the history
Release/1.1.0
- adjust extension descirption
- remove when clause from showHistory command
- immediatly paste selected code from history and make it configurable
- adding badges
- update command copy title
  • Loading branch information
nkosakul authored Dec 14, 2021
2 parents bc3c504 + 82f9a80 commit a39ba87
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[![Marketplace](https://vsmarketplacebadge.apphb.com/version-short/nkosakul.copy-cat.svg)](https://marketplace.visualstudio.com/items?itemName=nkosakul.copy-cat)
![Installs](https://vsmarketplacebadge.apphb.com/installs/nkosakul.copy-cat.svg)

# Copy Cat

A VSCode extension that stores your clipboard to a history and hands it back to you, whenever you want it.
Stores your clipboard to a history and hands it back to you, whenever you want it.

-----------------------------------------------------------------------------------------------------------
## Features
Expand Down
24 changes: 20 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "copy-cat",
"displayName": "Copy Cat",
"description": "A clipboard history VSCode extension that stores what you copy and gives it to you when needed",
"description": "Stores a history of your copied code.",
"version": "1.0.0",
"publisher": "nkosakul",
"engines": {
Expand Down Expand Up @@ -51,10 +51,19 @@
"type": "boolean",
"default": true,
"description": "Persist history between sessions."
},
"copy-cat.immediatelyPasting": {
"type": "boolean",
"default": true,
"description": "Immediately paste code, when selecting item in QuickPick Menu"
}
}
},
"commands": [
{
"command": "copy-cat.copy",
"title": "Copy Cat: Copy And Save To History"
},
{
"command": "copy-cat.showHistory",
"title": "Copy Cat: Show History"
Expand All @@ -80,10 +89,17 @@
{
"command": "copy-cat.showHistory",
"key": "shift+ctrl+c",
"mac": "shift+cmd+c",
"when": "editorTextFocus"
"mac": "shift+cmd+c"
}
]
],
"menus": {
"editor/context": [
{
"command": "copy-cat.copy",
"group": "9_cutcopypaste"
}
]
}
},
"scripts": {
"vscode:prepublish": "yarn run esbuild-base -- --minify",
Expand Down
40 changes: 31 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,37 @@ const showHistory = (history: LocalStorageService): void => {
return;
}

vscode.window.showQuickPick(historyItems, {
title: 'Copy Cat History',
placeHolder: 'Copy a line to the clipboard',
matchOnDescription: false,
matchOnDetail: true,
onDidSelectItem: (item: string) => {
vscode.env.clipboard.writeText(item);
},
});
vscode.window
.showQuickPick(historyItems, {
title: 'Copy Cat History',
placeHolder: 'Copy a line to the clipboard',
matchOnDescription: false,
matchOnDetail: true,
})
.then(item => {
const immediatelyPasting: boolean = vscode.workspace
.getConfiguration('copy-cat')
.get('immediatelyPasting', true);

if (immediatelyPasting) {
const activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
activeEditor
.edit(textInserter => {
// Delete currently selected code
textInserter.delete(activeEditor.selection);
})
.then(() => {
activeEditor.edit(textInserter => {
// Immediately insert code from list
item && textInserter.insert(activeEditor.selection.start, item);
});
});
}
} else {
item && vscode.env.clipboard.writeText(item);
}
});
};

// this method is called when your extension is activated
Expand Down

0 comments on commit a39ba87

Please sign in to comment.