Skip to content

Commit 728ccdd

Browse files
If the user ever used the console, hide the hint
1 parent bf34bbf commit 728ccdd

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/better_errors/templates/main.erb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,31 @@
849849
this.inputElement = this.container.querySelector("input");
850850
this.outputElement = this.container.querySelector("pre");
851851

852+
this.hasUsedConsole = document.cookie.split('; ').find(function(cookie) {
853+
return cookie.startsWith('BetterErrors-has-used-console=');
854+
});
855+
if (this.hasUsedConsole) {
856+
this.hideConsoleHint();
857+
}
858+
852859
var self = this;
853860
this.inputElement.onkeydown = function(ev) {
854861
self.onKeyDown(ev);
862+
if (!self.hasUsedConsole) {
863+
self.hideConsoleHint();
864+
self.hasUsedConsole = true;
865+
document.cookie = "BetterErrors-has-used-console=true;path=/;max-age=31536000;samesite"
866+
}
855867
};
856868

857869
this.setPrompt(">>");
858870

859871
REPL.all[this.index] = this;
860-
}
872+
};
873+
874+
REPL.prototype.hideConsoleHint = function() {
875+
document.querySelector('#live-shell-hint').style["display"] = "none";
876+
};
861877

862878
REPL.prototype.focus = function() {
863879
this.inputElement.focus();

lib/better_errors/templates/variable_info.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</header>
2626

2727
<% if BetterErrors.binding_of_caller_available? && @frame.frame_binding %>
28-
<div class="hint">
28+
<div class="hint" id='live-shell-hint'>
2929
This is a live shell. Type in here.
3030
</div>
3131

0 commit comments

Comments
 (0)