Giter Club home page Giter Club logo

Comments (33)

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

Btw to check the state of the repl, you can use ':show'

from irust.

fdncred avatar fdncred commented on July 19, 2024

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 vscode-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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

:edit notepad works. I bet it's just looking for .exe in windows.

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

Does the second command work correctly on your case, I mean are changes reflected on irust?

from irust.

fdncred avatar fdncred commented on July 19, 2024

The second command only launches vscode, it's not hooked up to the :edit mechanism, if I understand what you're asking.

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

the ok msg needs to be printed only after the editor is closed.

Nope - it says Ok immediately.

from irust.

fdncred avatar fdncred commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

And even add a whitelist, what do you think?

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

':pop' is handy for single line errors
1 - let x ΓΉ= "hello";
2 - :pop
3 - up arrow, modify and enter

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

@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.

fdncred avatar fdncred commented on July 19, 2024

i'd be willing to give that a try.

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

@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.

sigmaSd avatar sigmaSd commented on July 19, 2024

the command is :sync btw

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

a bit better with 5e54281

from irust.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

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.

fdncred avatar fdncred commented on July 19, 2024

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.

sigmaSd avatar sigmaSd commented on July 19, 2024

cool! #68

from irust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.