diff --git a/CHANGELOG.md b/CHANGELOG.md index 668d8ff..64dd1f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + + +## 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 + ## 0.0.8 (2019-02-19) diff --git a/extension.js b/extension.js index ff3d6cb..1552e5d 100644 --- a/extension.js +++ b/extension.js @@ -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); @@ -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)`; } diff --git a/images/icon.png b/images/icon.png index 1c5bd33..6a57bcc 100644 Binary files a/images/icon.png and b/images/icon.png differ diff --git a/package.json b/package.json index d08ef62..08f5227 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "onCommand:extension.copyPythonPath", "onCommand:extension.generateImportStatement" ], + "author": { + "name": "Mathias Gesbert" + }, "categories": [ "Other" ], @@ -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" } @@ -42,9 +45,13 @@ ] } }, + "contributors": [ + "Nicolas Faurie" + ], "dependencies": { "clipboardy": "^1.2.3" }, + "description": "Python imports utils.", "devDependencies": { "@types/mocha": "^2.2.42", "@types/node": "^7.0.43", @@ -52,19 +59,14 @@ "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", @@ -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" }