From c6fde979380099f23744e3e8ade795c95912542a Mon Sep 17 00:00:00 2001 From: Kun Ren Date: Sat, 18 May 2024 08:21:58 +0800 Subject: [PATCH] Fix code --- .vscodeignore | 7 ++----- package.json | 24 ++++++------------------ src/helpViewer/helpPreviewer.ts | 5 ++++- src/helpViewer/index.ts | 2 +- yarn.lock | 9 ++++++++- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/.vscodeignore b/.vscodeignore index 639bde9b7..8681f02ad 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -19,9 +19,6 @@ webpack.config.js .markdownlint.json .eslintignore -# node_modules #withWebpack -# out/ #withWebpack + node_modules + out/ -# withoutWebpack: -dist -# /withoutWebpack diff --git a/package.json b/package.json index d726d5af4..434e22878 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "onCommand:r.runSelectionInActiveTerm", "onWebviewPanel:rhelp" ], - "main": "./out/extension", + "main": "./dist/extension", "contributes": { "terminal": { "profiles": [ @@ -1437,7 +1437,7 @@ "default": [], "markdownDescription": "Additional library paths to launch R background processes (R languageserver, help server, etc.). These paths will be appended to `.libPaths()` on process startup. It could be useful for projects with [renv](https://rstudio.github.io/renv/index.html) enabled." }, - "r.useRenvLibPath" : { + "r.useRenvLibPath": { "type": "boolean", "default": false, "markdownDescription": "Use renv library paths to launch R background processes (R languageserver, help server, etc.)." @@ -2076,28 +2076,15 @@ ] }, "scripts": { - "vscode:prepublish": "tsc -p . && tsc -p ./html/help && tsc -p ./html/httpgd", - "compile": "tsc -p . && tsc -p ./html/help && tsc -p ./html/httpgd", - "watch": "tsc -p . --watch", + "vscode:prepublish": "tsc -p ./html/help && tsc -p ./html/httpgd && webpack --mode production", + "compile": "tsc -p ./html/help && tsc -p ./html/httpgd && webpack --mode none", + "watch": "webpack --mode none --watch", "watchHelp": "tsc -p ./html/help --watch", "watchHttpgd": "tsc -p ./html/httpgd --watch", "pretest": "tsc -p ./", "test": "node ./out/test/runTest.js", "lint": "eslint src --ext ts" }, - "withWebpack": { - "scripts": { - "vscode:prepublish": "tsc -p ./html/help && tsc -p ./html/httpgd && webpack --mode production", - "compile": "tsc -p ./html/help && tsc -p ./html/httpgd && webpack --mode none", - "watch": "webpack --mode none --watch", - "watchHelp": "tsc -p ./html/help --watch", - "watchHttpgd": "tsc -p ./html/httpgd --watch", - "pretest": "tsc -p ./", - "test": "node ./out/test/runTest.js", - "lint": "eslint src --ext ts" - }, - "main": "./dist/extension" - }, "devDependencies": { "@types/cheerio": "^0.22.29", "@types/ejs": "^3.0.6", @@ -2126,6 +2113,7 @@ "webpack-cli": "^4.7.2" }, "dependencies": { + "@types/highlight.js": "^10.1.0", "ag-grid-community": "^31.3.2", "cheerio": "1.0.0-rc.12", "crypto": "^1.0.1", diff --git a/src/helpViewer/helpPreviewer.ts b/src/helpViewer/helpPreviewer.ts index 75268f7da..4d7ba7537 100644 --- a/src/helpViewer/helpPreviewer.ts +++ b/src/helpViewer/helpPreviewer.ts @@ -146,7 +146,7 @@ export class RLocalHelpPreviewer { this.cachedPackageInfo = undefined; this.callPreviewListener(); }; - const manDirListener: fs.WatchListener = (event: fs.WatchEventType, filename: string) => { + const manDirListener: fs.WatchListener = (event: fs.WatchEventType, filename: string | null) => { if(this.isDisposed){ return; } @@ -154,6 +154,9 @@ export class RLocalHelpPreviewer { this.dispose(true); return; } + if (filename === null) { + return; + } const fullPath = path.join(this.manDir, filename); // The cache is only initialized when it is needed for the first time: if(this.cachedRdAliases){ diff --git a/src/helpViewer/index.ts b/src/helpViewer/index.ts index 227e9cdde..3b0f62770 100644 --- a/src/helpViewer/index.ts +++ b/src/helpViewer/index.ts @@ -730,7 +730,7 @@ function pimpMyHelp(helpFile: HelpFile): HelpFile { // apply syntax highlighting to each code section: codeSections.each((i, section) => { - const styledCode = hljs.highlight($(section).text() || '', { + const styledCode = hljs.default.highlight($(section).text() || '', { language: 'r', }); $(section).html(styledCode.value); diff --git a/yarn.lock b/yarn.lock index f3dae3457..fa4ca014c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -266,6 +266,13 @@ "@types/minimatch" "*" "@types/node" "*" +"@types/highlight.js@^10.1.0": + version "10.1.0" + resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-10.1.0.tgz#89bb0c202997d7a90a07bd2ec1f7d00c56bb90b4" + integrity sha512-77hF2dGBsOgnvZll1vymYiNUtqJ8cJfXPD6GG/2M0aLRc29PkvB7Au6sIDjIEFcSICBhCh2+Pyq6WSRS7LUm6A== + dependencies: + highlight.js "*" + "@types/js-yaml@^4.0.2": version "4.0.3" resolved "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.3.tgz" @@ -1665,7 +1672,7 @@ he@1.2.0: resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -highlight.js@^11.9.0: +highlight.js@*, highlight.js@^11.9.0: version "11.9.0" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.9.0.tgz#04ab9ee43b52a41a047432c8103e2158a1b8b5b0" integrity sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==