diff --git a/.vscodeignore b/.vscodeignore index f717712..c2a5c7d 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -13,6 +13,14 @@ tsconfig.json personal/** .travis.yml dependencygraph.svg +.hypothesis +.env +.vscode-test.js +areplDemoGif2.gif +copy_backend.bat +notes.txt +*.code-workspace +tslint.json #pycharm dir .idea/** # coverage output diff --git a/README.md b/README.md index e4afcba..2fe8b65 100644 --- a/README.md +++ b/README.md @@ -145,38 +145,6 @@ I have [overridden the display](https://github.com/Almenon/AREPL-backend/blob/ma If you want a type to be displayed in a particular manner just [file an issue](https://github.com/Almenon/AREPL-vscode/issues) -### #$save - -*This is buggy and I would suggest using the [arepl_store variable](https://github.com/Almenon/AREPL-vscode/wiki/Caching-data-between-runs) instead* - -If you want to avoid a section of code being executed in real-time (due to it being slow or calling external resources) you can use \#\$save. For example: - -```python -def largest_prime_factor(n): - i = 2 - while i * i <= n: - if n % i: - i += 1 - else: - n //= i - return n - -# this takes a looonnggg time to execute -result = largest_prime_factor(8008514751439999) - -#$save -print("but now that i saved i am back to real-time execution") -``` - -```python -import random -x = random.random() -#$save -print(x) # this number will not change when editing below the #$save line -``` - -Please note that \#\$save [does not work](https://github.com/Almenon/AREPL-vscode/issues/53) with certain types, like generators. If #$save fails in pickling the code state [file an issue](https://github.com/Almenon/AREPL-vscode/issues) so I can look into it. - ### More Stuff Check out the [wiki](https://github.com/Almenon/AREPL-vscode/wiki)! diff --git a/changelog.md b/changelog.md index 0eeb39b..9488d24 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ 🐛 As a consequence of above, AREPL will no longer crash when there is a infinite loop 🐛 As a consequence of above, pandas now works better 🐛 As a consequence of above, boto3 now works better +🔧 `#$save` feature has been removed +🔧 Removed `keepPreviousVars` setting +🔧 `arepl_store` variable has been removed. ## v2.0.5 (3/5/2023) 🐛🚀 🐛 [Fixed inconsistent variable display in certain cases](https://github.com/Almenon/AREPL-vscode/issues/3716) diff --git a/package-lock.json b/package-lock.json index 297513a..be65ad5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "SEE LICENSE IN ", "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.3" + "arepl-backend": "^3.0.5" }, "devDependencies": { "@types/mocha": "^10.0.9", @@ -631,9 +631,9 @@ } }, "node_modules/arepl-backend": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.3.tgz", - "integrity": "sha512-ruzBMW4/szcfkxlpuroWiJsnI1Rc9odFZOjh60tvLbrFC7dFhchWiB9SVRDve5XMIW6spkp2a/oN7t/SBzCCJw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.5.tgz", + "integrity": "sha512-OE/EEmq3uplEDGzAl5V+JTCNU2bIfBGXUTb0ExYO4jkPPB7ZdSRlba0IYGDv0VSyBiVRZWE9gXtZEdet2Ynudw==", "dependencies": { "python-shell": "^5.0.0" } @@ -2934,9 +2934,9 @@ } }, "arepl-backend": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.3.tgz", - "integrity": "sha512-ruzBMW4/szcfkxlpuroWiJsnI1Rc9odFZOjh60tvLbrFC7dFhchWiB9SVRDve5XMIW6spkp2a/oN7t/SBzCCJw==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/arepl-backend/-/arepl-backend-3.0.5.tgz", + "integrity": "sha512-OE/EEmq3uplEDGzAl5V+JTCNU2bIfBGXUTb0ExYO4jkPPB7ZdSRlba0IYGDv0VSyBiVRZWE9gXtZEdet2Ynudw==", "requires": { "python-shell": "^5.0.0" } diff --git a/package.json b/package.json index 585dd99..20f0717 100644 --- a/package.json +++ b/package.json @@ -193,11 +193,6 @@ "type": "boolean", "default": false, "description": "Whether to automatically load django models. This setting doesn't actually do anything yet. See https://github.com/Almenon/AREPL-vscode/issues/279" - }, - "AREPL.keepPreviousVars": { - "type": "boolean", - "default": false, - "description": "If set to true AREPL will add onto the local state each run instead of clearing it and starting fresh." } } }, @@ -292,7 +287,7 @@ }, "dependencies": { "@vscode/extension-telemetry": "^0.9.7", - "arepl-backend": "^3.0.3" + "arepl-backend": "^3.0.5" }, "bugs": { "url": "https://github.com/almenon/arepl-vscode-wordcount/issues", diff --git a/src/PreviewManager.ts b/src/PreviewManager.ts index 5580b99..a2444ed 100644 --- a/src/PreviewManager.ts +++ b/src/PreviewManager.ts @@ -142,7 +142,6 @@ export default class PreviewManager { const data: ExecArgs = { evalCode: codeLines, filePath, - savedCode: '', usePreviousVariables: true, show_global_vars: settingsCached.get('showGlobalVars'), default_filter_vars: settingsCached.get('defaultFilterVars'), diff --git a/src/pythonPanelPreview.ts b/src/pythonPanelPreview.ts index 9ffded0..70dba24 100644 --- a/src/pythonPanelPreview.ts +++ b/src/pythonPanelPreview.ts @@ -31,21 +31,22 @@ export default class PythonPanelPreview {

Examples

Simple List

- -x = [1,2,3] +x = [1,2,3] y = [num*2 for num in x] print(y)

Dumping

- -from arepl_dump import dump +from arepl_dump import dump def milesToKilometers(miles): kilometers = miles*1.60934 @@ -66,8 +67,7 @@ a=2

Turtle

- -import turtle +import turtle # window in right hand side of screen turtle.setup(500,500,-1,0) @@ -80,15 +80,15 @@ turtle.left(90)

Web call

- -import requests +import requests import datetime as dt +# We don't want to spam an API with calls every time we stop typing +# so we use #$end to deactivate real-time mode for everything afterwords +# then we can run blocks of code as desired with command-enter or control-enter +#$end r = requests.get("https://api.github.com") -#$save -# #$save saves state so request is not re-executed when modifying below - now = dt.datetime.now() if r.status_code == 200: print("API up at " + str(now)) diff --git a/src/toAREPLLogic.ts b/src/toAREPLLogic.ts index 4480c62..8a2ed2f 100644 --- a/src/toAREPLLogic.ts +++ b/src/toAREPLLogic.ts @@ -7,7 +7,6 @@ import {settings} from "./settings" */ export class ToAREPLLogic{ - lastSavedSection = "" lastCodeSection = "" lastEndSection = "" @@ -33,21 +32,15 @@ export class ToAREPLLogic{ let codeLines = text.split(eol) - let savedLines: string[] = [] let startLineNum = 0 let endLineNum = codeLines.length codeLines.forEach((line, i) => { - if(line.trimRight().endsWith("#$save")){ - savedLines = codeLines.slice(0, i + 1) - startLineNum = i+1 - } - if(line.trimRight().endsWith("#$end")){ + if(line.trimEnd().endsWith("#$end")){ endLineNum = i+1 return } }); - const endSection = codeLines.slice(endLineNum).join(eol) codeLines = codeLines.slice(startLineNum, endLineNum) const unsafeKeywords = settingsCached.get('unsafeKeywords') @@ -60,22 +53,17 @@ export class ToAREPLLogic{ const data: ExecArgs = { evalCode: codeLines.join(eol), filePath, - savedCode: savedLines.join(eol), - usePreviousVariables: settingsCached.get('keepPreviousVars'), show_global_vars: showGlobalVars, default_filter_vars: settingsCached.get('defaultFilterVars'), default_filter_types: settingsCached.get('defaultFilterTypes') } - // user should be able to rerun code without changing anything - // only scenario where we dont re-run is if just end section is changed - if(endSection != this.lastEndSection && data.savedCode == this.lastSavedSection && data.evalCode == this.lastCodeSection){ + if(data.evalCode == this.lastCodeSection){ + // nothing changed, no point in rerunning return false } this.lastCodeSection = data.evalCode - this.lastSavedSection = data.savedCode - this.lastEndSection = endSection this.PythonExecutor.execCode(data)