Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign global variables to console evals #2724

Merged
merged 4 commits into from
Jan 10, 2020

Conversation

Phlosioneer
Copy link
Contributor

Similar to google chrome's debug console. Makes working with intermediate values easier.

Similar to google chrome's debug console. Makes working with
intermediate values easier.
@Phlosioneer Phlosioneer changed the title Assign global variable console evals Assign global variables to console evals Jan 3, 2020
@bjorn
Copy link
Member

bjorn commented Jan 8, 2020

Hmm, is this Chrome specific? I don't see this behavior in the console in Brave, where actually $0, $1 etc. seem to refer to various elements on the page, $0 being the last clicked one. I'm not sure about the visual noise this is adding and it seems to me preferable to assign the returned values to named variables explicitly.

What I did notice is that $_ can be used to get the value of the last executed statement. Maybe it's a good compromise?

@Phlosioneer
Copy link
Contributor Author

the problem with assigning it to variables is that when you do that, nothing is printed. The value of the expression var x = 1 is undefined, not 1.

The problem with restricting it to $_ is that you might need something from a few lines above without realizing you need it at that time. It's annoying to write var $0 = ... etc every time I type a line just in case I need it later.

And you appear to be correct, in chrome $0, $1, etc. are the 1st, 2nd, etc. elements you select in the web page. Hm, what interpreter was I thinking of then?

I'd still like this change but I'm open to other ways of accomplishing the same thing. Having this speeds up my script debugging by a lot. What if the feature is enabled but it didn't print out the "$0 = ..." stuff unless a checkmark in the preferences was set?

@bjorn
Copy link
Member

bjorn commented Jan 9, 2020

Maybe we could just make it a little less noisy, by showing it in a darker gray for example?

Phlosioneer and others added 3 commits January 10, 2020 03:36
@bjorn
Copy link
Member

bjorn commented Jan 10, 2020

the problem with assigning it to variables is that when you do that, nothing is printed. The value of the expression var x = 1 is undefined, not 1.

Note that while indeed var x = 1 evaluates to undefined, the simpler form x = 1 does evaluate to 1 and sets a global variable x.

But, I think the dimming helped reduce the noise so let's just merge it now. :-)

@bjorn bjorn merged commit c37c781 into mapeditor:master Jan 10, 2020
@Phlosioneer
Copy link
Contributor Author

Phlosioneer commented Jan 10, 2020

Ah, I wasn't able to prevent the wrapping. Good idea to use span and   together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants