Comments (33)
This is because of #62
Every statement used to require ';' at the end, but now there are some exception that gets immediately parsed into the repl (like function definition see https://github.com/sigmaSd/IRust/blob/master/src/irust/parser.rs#L303)
I found overall the convenience of not having to type ';' is really nice also users don't get confused as it happens in the issue I linked above
So currently here's what you can do
1- type ':reset' this will reset the repl then go up and modify the function
2- for single lines you can use ':pop' wich deletes last line written
3- use ':edit nano(or any editor)'
Arguably we can add a :pop_last_block but I'm not sure if its really needed
from irust.
Btw to check the state of the repl, you can use ':show'
from irust.
Does it check your path for executables?
In: :edit vscode-insiders
waiting for vscode-insiders...
The system cannot find the file specified. (os error 2)
[Edit]
oof - i thought i figured it out because it's not vs
code-insiders, it's just code-insiders
but that didn't make any difference either. btw - if it's an consequence, code-insiders is a .cmd file.
from irust.
it calls std::process::Command::new(editor)
so it should work if its in $PATH https://github.com/sigmaSd/IRust/blob/master/src/irust/parser.rs#L355
from irust.
:edit notepad
works. I bet it's just looking for .exe
in windows.
from irust.
Are you sure its on path, you can test by running code-insiders on cmd.
I just tried code and atom on linux, looks they're a bit problematic ( irust doesn't wait for them to spawn), I'm pretty sure it used to work, the problem is probably is that the initial process calls another one then exits, but anyhow this is another issue.
from irust.
Are you sure its on path, you can test by running code-insiders on cmd.
yes sir. I just checked again to be sure.
from irust.
Ok I'll grab a windows machine and debug it later.
You can test std::process:Command::new("code-insiders").spawn().unwrap().wait()
on irust btw.
Also does it work if you use std::process:Command::new("cmd").arg("/C").arg("code-insiders").spawn().unwrap().wait()
from irust.
Also just a sanity check can you try echo %PATH:;=&echo.%
and check if it contains the path to code-insiders, maybe there is a way to use executable outside of path in cmd, I'm not really sure how windows works
from irust.
this std::process::Command::new("code-insiders").spawn().unwrap().wait()
does not work and give the same error message as above.
this std::process:Command::new("cmd").arg("/C").arg("code-insiders").spawn().unwrap().wait()
does launch vscode-insiders.
from irust.
Does the second command work correctly on your case, I mean are changes reflected on irust?
from irust.
The second command only launches vscode, it's not hooked up to the :edit
mechanism, if I understand what you're asking.
from irust.
for the edit command to actually work correctly:
In: :edit micro
waiting for micro...
Ok!
the ok msg needs to be printed only after the editor is closed.
Currently I noticed an issue on linux is that Command::spawn().wait() doesn't wait on forks so it means complex program like electron one wont be handled correctly, so I'm asking if its the same on windows
from irust.
I changed 355 to this
std::process::Command::new("cmd").arg("/c").arg(editor)
.arg(&*MAIN_FILE)
.spawn()?
.wait()?;
and it launches the file fine however my edits are not consumed i.e. put back in the main.rs file when i save and close.
from irust.
the ok msg needs to be printed only after the editor is closed.
Nope - it says Ok
immediately.
from irust.
btw - if i have code-insiders
open, it just opens another tab with the file. I make changes to the file, save it and close the file. I don't close the editor.
from irust.
yes that's problematic, I don't see a way around closing the editor.
Does notepad work btw?
Btw I mostly use it with vi, nano, micro, maybe I should just mention its made for terminal editors, cause it looks that supporting big editors is not easy and also I doubt its really that important
from irust.
And even add a whitelist, what do you think?
from irust.
Also regarding the original issue, do you think the available ways I mentioned are enough or is there some other method you want to see added?
from irust.
Actually I don't feel strongly for the whitelist, most editors I tested works (geany, gnome-builder, gedit), I guess its really electron apps that are problematic, I think regarding this issue I can just document it
from irust.
yes that's problematic, I don't see a way around closing the editor.
Perhaps what you should do is look at the last modified datetime of the file and store that in a var, then launch the editor, then when the last mod time changes, use it as if the editor closed.
Does notepad work btw?
yes
Btw I mostly use it with vi, nano, micro, maybe I should just mention its made for terminal editors, cause it looks that supporting big editors is not easy and also I doubt its really that important
If you're trying to be cross platform, it's not safe to assume people in windows will use vi/vim. notepad, notepad++, notepad2 are probably very safe. vscode is what a lot of people are using now cross platform so I think it'd be wise to support it.
whitelist
white list what? editors by platform?
original issue
I'm sitting on this at the moment. i really don't like having to have specialized code ';' in irust. I also don't like having the ability to up-arrow to change something and then it making two copies. usually, when a user hits the up-arrow in a cli app, it's to change something and since you already display the code that needs to be changed, not replacing it alltogether may be a mistake.
i like the :edit
command, not sure what to do with the :pop
command since it seems different than pop/stash.
from irust.
I think the issue here, that irust maybe should not accept invalid input, but this is something I really wanted to avoid since it means It will have to recompile every input instead of only the input that contains expression
I'm sitting on this at the moment. i really don't like having to have specialized code ';' in irust.
I actually did the same for a long time but the issue I mentioned above happened multiple times and people always got confused coming from ipython (which irust try to mimic its design to a point) that's when I decided that it must be worth it
from irust.
':pop' is handy for single line errors
1 - let x ΓΉ= "hello";
2 - :pop
3 - up arrow, modify and enter
from irust.
Perhaps what you should do is look at the last modified datetime of the file and store that in a var, then launch the editor, then when the last mod time changes, use it as if the editor closed.
Its tricky I can set for example a notify handler, I can see this happen asynchronously, the editor opened by the user or in fact any changes to irust/src/main.rs triggers an event that we handle by re parsing the code.
I guess its possible, I would prefer just improving the current method though instead of the added complexity of handling async events, but its something to consider.
from irust.
@fdncred I can also workaround the issue, for example add a command ':parse_repl' (or something) so it works like this for currently broken editors
1- :edit atom
2- make the changes and save
3- use :parse_repl which sync the repl with the modified code
The benefit is you can keep the editor open and actually make the changes whenever as long as you use the new command to sync afer
from irust.
i'd be willing to give that a try.
from irust.
@fdncred you can test here https://github.com/sigmaSd/IRust/tree/sync_edit unfortunately it gets pretty ugly since it reveals the internals I'll see if I can do better
from irust.
the command is :sync btw
from irust.
a bit better with 5e54281
from irust.
I think I can do even better by evaluating using another file, leaving the original for cases like :edit, but the idea should be clear by now If you think this is good method I'll add it
from irust.
I pushed the changes I mentioned. Now I actually like the solution and the new command. I'll wait for your feedback before pushing this to master though.
from irust.
ya, i compiled and ran in the sync_edit
branch. things look good. i can code with code-insiders
via the :edit
command and then when i type :sync
it replaces my code. nice!
from irust.
cool! #68
from irust.
Related Issues (20)
- Use `rustyline` or `reedline` for input? HOT 1
- Move theme settings from config.toml to themes config
- Improve Jupyter kernel support HOT 7
- typing twice in windows with crossterm-0.26+ HOT 2
- Can irust repl evaluate code with release mode instead of debug mode? HOT 3
- Cannot use two `irust_repl`s at the same time. HOT 27
- Rust analyzer is not working on Windows HOT 6
- Interactive usage HOT 3
- IRust installation fails due to use of unstable library feature 'once_cell' HOT 3
- FileNotFoundError while `python -m irust_kernel.install` HOT 1
- cargo-edit requires --path argument for a local dependency after version 0.9.1 HOT 2
- irust doesn't display Thai text properly. HOT 1
- Unclear documentation on importing local crates HOT 5
- Autocomplete doesn't work HOT 10
- untitled issue HOT 4
- Proposal: Split eval output HOT 3
- Option to specify config.toml path HOT 6
- Support nREPL protocol? HOT 2
- Failed to format error output HOT 2
- Logo missing on Jupyter lab launcher page HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from irust.