diff --git a/changelog.md b/changelog.md index 1471318..a6c014a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,13 @@ # Changelog +## 1.1.1 +- Fixed expressions with escaped backslashes not displaying previews. +- Fixed unescaped characters breaking the preview formatting. + ## 1.1.0 - Changed display of hints from an inline hint to be in a hover menu. - Changed result to include a list of several sample matches. +- Fixed extension ocasionally crashing. ## 1.0.0 - Added inlay hints to preview regular expressions. diff --git a/package-lock.json b/package-lock.json index 1658e3e..11f4129 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "inlay-regex", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "inlay-regex", - "version": "1.1.0", + "version": "1.1.1", "license": "ISC", "dependencies": { "randexp": "~0.5.3" }, "devDependencies": { "@types/node": "ts4.3", - "@types/vscode": "^1.63.1", + "@types/vscode": "1.50.0", "typescript": "^4.5.4" }, "engines": { @@ -27,9 +27,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.63.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.1.tgz", - "integrity": "sha512-Z+ZqjRcnGfHP86dvx/BtSwWyZPKQ/LBdmAVImY82TphyjOw2KgTKcp7Nx92oNwCTsHzlshwexAG/WiY2JuUm3g==", + "version": "1.50.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.50.0.tgz", + "integrity": "sha512-QnIeyi4L2DiD9M2bAQKRzT/EQvc80qP9UL6JD5TiLlNRL1khIDg4ej4mDSRbtFrDAsRntFI1RhMvdomUThMsqg==", "dev": true }, "node_modules/drange": { @@ -82,9 +82,9 @@ "dev": true }, "@types/vscode": { - "version": "1.63.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.1.tgz", - "integrity": "sha512-Z+ZqjRcnGfHP86dvx/BtSwWyZPKQ/LBdmAVImY82TphyjOw2KgTKcp7Nx92oNwCTsHzlshwexAG/WiY2JuUm3g==", + "version": "1.50.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.50.0.tgz", + "integrity": "sha512-QnIeyi4L2DiD9M2bAQKRzT/EQvc80qP9UL6JD5TiLlNRL1khIDg4ej4mDSRbtFrDAsRntFI1RhMvdomUThMsqg==", "dev": true }, "drange": { diff --git a/package.json b/package.json index e268e56..a24d0f9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "inlay-regex", "displayName": "Inlay Regex Previewer", - "version": "1.1.0", + "version": "1.1.1", "description": "Generate sample matches when a regular expression is hovered over.", "categories": [ "Debuggers", @@ -28,7 +28,7 @@ }, "devDependencies": { "@types/node": "ts4.3", - "@types/vscode": "^1.63.1", + "@types/vscode": "1.50.0", "typescript": "^4.5.4" }, "engines": { diff --git a/src/extension.ts b/src/extension.ts index 1d7ecff..1fb8c58 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,13 +3,12 @@ import RandExp from 'randexp'; const languages = ['javascript', 'typescript', 'coffeescript', 'ruby', 'groovy']; const numPreviews = 5; +const regexRegex = /\/((?![*+?])(?:[^\r\n\[/\\]|\\.|\[(?:[^\r\n\]\\]|\\.)*\])+)\/[gimusy]*/; // so:17843691 function provideHover(document: vscode.TextDocument, position: vscode.Position) { // Get content of line - const regex = /\/.*?[^\\]\/[gimusy]*/g; - const range = document.getWordRangeAtPosition(position, regex); + const range = document.getWordRangeAtPosition(position, regexRegex); const match = document.getText(range); - console.debug({match}) // Exit if no regex selected if (match.includes('\n')) return; // Create preview regexes @@ -23,7 +22,7 @@ function provideHover(document: vscode.TextDocument, position: vscode.Position) } } // Return - const previewText = previews.map(text => '\n- ``' + text + '``').join(''); + const previewText = previews.map(text => '\n- `` ' + text + ' ``').join(''); const result = new vscode.MarkdownString(`**Possible matches:**\n${previewText}`); return new vscode.Hover(result); } diff --git a/test/test.js b/test/test.js index a4f0fc0..1574964 100644 --- a/test/test.js +++ b/test/test.js @@ -5,4 +5,6 @@ const regex = /\/.*?[^\\]\/[gimusy]*?/g; if ("string".match(/s..\w+$/)) console.log('match'); /a/, /b/; /.+/ - +const escape = /a\\b/ + /!\\/; +const look = /abc(?=def)/; +const lookNested = /abc(?=(?