HuyaneMatsu / scarletio

Asynchronous blackmagic & Witchcraft
Other
14 stars 1 forks source link

Console prefix autoremove #9

Closed HuyaneMatsu closed 2 years ago

HuyaneMatsu commented 2 years ago

When pasting into scalretio repl, console prefixes should be auto removed if detectable.

HuyaneMatsu commented 2 years ago

include: In [n]: ...: >>> >>>> ... ....

Note: every prefix ends with a space character.

WizzyGeek commented 2 years ago

-1 on this, copying without prefix is something that can be considered much more useful than pasting malformed python code.

HuyaneMatsu commented 2 years ago

@WizzyGeek Since I don't know how to format copying, I format pasting.

WizzyGeek commented 2 years ago

@HuyaneMatsu however removing these prefixes essentially requires building a context dependent parser at minimum... It is a bit too much work and I consider it useless since you usually don't copy from one repl session to another

I would however advocate repl commands which would copy an input to clipboard if possible

HuyaneMatsu commented 2 years ago

@HuyaneMatsu however removing these prefixes essentially requires building a context dependent parser at minimum...

Already did it 💨 at https://github.com/HuyaneMatsu/scarletio/commit/123eba5f6499d62eaa0a71961752011aea10bcb9

WizzyGeek commented 2 years ago

@HuyaneMatsu however removing these prefixes essentially requires building a context dependent parser at minimum...

Already did it 💨 at https://github.com/HuyaneMatsu/scarletio/commit/123eba5f6499d62eaa0a71961752011aea10bcb9

Doing this with regex further allows malformed inputs... For example

In [10]: a = """
...:         
...:      
...: """
...: 

Consider the above input (ignore the inaccurate begin, continue, and last line prompts used, I can't recall them) where line 2 and 3 has spaces and yet they get matched to the regex and change string content

Such an input potentially will change the output of the code (eg: array[len(a)]) Hence you require a context dependent parser still, If I haven't misinterpreted the code for trimming I think this holds true....

HuyaneMatsu commented 2 years ago

Additional empty spaces after prefix are not removed obviously. If you mean that of course. Those are actually removed by the compiler. :kekw:

Obviously every auto-formatting feature can hurt, but at most of the cases they help way more than hurt.

At this exact case the biggest "hurting" factor is that most repl-s do not have this feature, so users might have difficulty switching away.

HuyaneMatsu commented 2 years ago

Has been pushed 👌🏻