Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<a name="0.0.9"></a>

## 0.0.9 (2019-02-20)

### Bug Fixes

- **syntax:** avoid generating import statements when selecting text which is not a valid variable name
- **logo:** white text

<a name="0.0.8"></a>

## 0.0.8 (2019-02-19)
Expand Down
6 changes: 3 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function copyPythonPath(uri) {
const pythonPath = getPythonPath(filePath);
const selections = vscode.window.activeTextEditor.selections
.map(s => vscode.window.activeTextEditor.document.getText(s))
.filter(s => !!s && !s.includes("\n"));
.filter(s => !!s && !s.includes("\n") && !s.trim().includes(" "));
if (pythonPath && selections.length > 0) {
const importStatement = generateImportStatement(pythonPath, selections);
clipboardy.writeSync(importStatement);
Expand All @@ -55,10 +55,10 @@ function generateImportStatement(pythonPath, selections) {
if (selections.length == 0) {
return `import ${pythonPath}`;
} else if (selections.length == 1) {
const selection = selections[0];
const selection = selections[0].trim();
return `from ${pythonPath} import ${selection}`;
}
const selection = selections.map(s => `\t${s},`).join("\n");
const selection = selections.map(s => `\t${s.trim()},`).join("\n");
return `from ${pythonPath} import (\n${selection}\n)`;
}

Expand Down
Binary file modified images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 21 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"onCommand:extension.copyPythonPath",
"onCommand:extension.generateImportStatement"
],
"author": {
"name": "Mathias Gesbert"
},
"categories": [
"Other"
],
Expand All @@ -16,18 +19,18 @@
}
],
"menus": {
"editor/title/context": [
"editor/context": [
{
"command": "extension.copyPythonPath",
"when": "resourceLangId == python",
"group": "1_cutcopypaste@30000",
"title": "Copy Python Path"
"group": "9_cutcopypaste@30000",
"title": "Copy Python Path",
"when": "resourceLangId == python"
}
],
"editor/context": [
"editor/title/context": [
{
"command": "extension.copyPythonPath",
"group": "9_cutcopypaste@30000",
"group": "1_cutcopypaste@30000",
"title": "Copy Python Path",
"when": "resourceLangId == python"
}
Expand All @@ -42,29 +45,28 @@
]
}
},
"contributors": [
"Nicolas Faurie"
],
"dependencies": {
"clipboardy": "^1.2.3"
},
"description": "Python imports utils.",
"devDependencies": {
"@types/mocha": "^2.2.42",
"@types/node": "^7.0.43",
"eslint": "^4.11.0",
"typescript": "^2.6.1",
"vscode": "^1.1.6"
},
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"description": "Python imports utils.",
"displayName": "Python Path",
"engines": {
"vscode": "^1.22.0"
},
"galleryBanner": {
"color": "#1e415e",
"theme": "dark"
},
"engines": {
"vscode": "^1.22.0"
},
"icon": "images/icon.png",
"main": "./extension",
"name": "python-path",
Expand All @@ -73,5 +75,9 @@
"type": "git",
"url": "https://github.com/mgesbert/vscode-python-path.git"
},
"version": "0.0.8"
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"version": "0.0.9"
}