Browse Source

Mitigate Ctrl+P/Ctrl+D differently.

Use fork to actually compile and run,
so in case of error default action won't run.
Herby Vojčík 5 years ago
parent
commit
c5cf093ce7
4 changed files with 91 additions and 105 deletions
  1. 3 20
      src/Helios-Debugger.js
  2. 1 4
      src/Helios-Debugger.st
  3. 73 55
      src/Helios-Workspace.js
  4. 14 26
      src/Helios-Workspace.st

+ 3 - 20
src/Helios-Debugger.js

@@ -769,35 +769,18 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
 return $recv($self._debuggerModel())._evaluate_(aString);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
-//>>excludeEnd("ctx");
-}))._tryCatch_((function(e){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-$recv($globals.ErrorHandler)._handleError_(e);
-return nil;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,2)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"doIt:",{aString:aString})});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "doIt: aString\x0a\x09^ [ self debuggerModel evaluate: aString ]\x0a\x09\x09tryCatch: [ :e | \x0a\x09\x09\x09ErrorHandler handleError: e.\x0a\x09\x09\x09nil ]",
-referencedClasses: ["ErrorHandler"],
+source: "doIt: aString\x0a\x09^ self debuggerModel evaluate: aString",
+referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["tryCatch:", "evaluate:", "debuggerModel", "handleError:"]
+messageSends: ["evaluate:", "debuggerModel"]
 }),
 $globals.HLDebuggerCodeModel);
 

+ 1 - 4
src/Helios-Debugger.st

@@ -199,10 +199,7 @@ debuggerModel: anObject
 !HLDebuggerCodeModel methodsFor: 'actions'!
 
 doIt: aString
-	^ [ self debuggerModel evaluate: aString ]
-		tryCatch: [ :e | 
-			ErrorHandler handleError: e.
-			nil ]
+	^ self debuggerModel evaluate: aString
 ! !
 
 HLBrowserCodeWidget subclass: #HLDebuggerCodeWidget

+ 73 - 55
src/Helios-Workspace.js

@@ -99,35 +99,18 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $recv((function(){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
 return $recv($self._environment())._evaluate_for_(aString,$self._receiver());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
-//>>excludeEnd("ctx");
-}))._tryCatch_((function(e){
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
-//>>excludeEnd("ctx");
-$recv($globals.ErrorHandler)._handleError_(e);
-return nil;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,2)});
-//>>excludeEnd("ctx");
-}));
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"doIt:",{aString:aString})});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString"],
-source: "doIt: aString\x0a\x09\x22Evaluate aString in the receiver's `environment`.\x0a\x09\x0a\x09Note: Catch any error and handle it manually, bypassing\x0a\x09boot.js behavior to avoid the browser default action on\x0a\x09ctrl+d/ctrl+p.\x0a\x09\x0a\x09See https://lolg.it/amber/amber/issues/882\x22\x0a\x0a\x09^ [ self environment evaluate: aString for: self receiver ]\x0a\x09\x09tryCatch: [ :e | \x0a\x09\x09\x09ErrorHandler handleError: e.\x0a\x09\x09\x09nil ]",
-referencedClasses: ["ErrorHandler"],
+source: "doIt: aString\x0a\x09^ self environment evaluate: aString for: self receiver",
+referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["tryCatch:", "evaluate:for:", "environment", "receiver", "handleError:"]
+messageSends: ["evaluate:for:", "environment", "receiver"]
 }),
 $globals.HLCodeModel);
 
@@ -313,7 +296,7 @@ $globals.HLCodeWidget);
 
 $core.addMethod(
 $core.method({
-selector: "browseIt",
+selector: "basicDoIt",
 protocol: "actions",
 fn: function (){
 var self=this,$self=this;
@@ -321,40 +304,58 @@ var result;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $early={};
-try {
-result=$recv((function(){
+var $1;
+$1=$self._model();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx2) {
+$ctx1.sendIdx["model"]=1;
 //>>excludeEnd("ctx");
-return $self._doIt();
+result=$recv($1)._doIt_($self._currentLineOrSelection());
+$recv($recv($self._model())._announcer())._announce_($recv($globals.HLDoItExecuted)._on_($self.model));
+return result;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+}, function($ctx1) {$ctx1.fill(self,"basicDoIt",{result:result})});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "basicDoIt\x0a\x09| result |\x0a\x0a\x09result := self model doIt: self currentLineOrSelection.\x0a\x09self model announcer announce: (HLDoItExecuted on: model).\x0a\x0a\x09^ result",
+referencedClasses: ["HLDoItExecuted"],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["doIt:", "model", "currentLineOrSelection", "announce:", "announcer", "on:"]
+}),
+$globals.HLCodeWidget);
+
+$core.addMethod(
+$core.method({
+selector: "browseIt",
+protocol: "actions",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-}))._on_do_($globals.Error,(function(exception){
+$recv((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-throw $early=[$recv($globals.ErrorHandler)._handleError_(exception)];
+return $recv($self._model())._browse_($self._basicDoIt());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({exception:exception},$ctx1,2)});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
-}));
-$recv($self._model())._browse_(result);
+}))._fork();
 return self;
-}
-catch(e) {if(e===$early)return e[0]; throw e}
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"browseIt",{result:result})});
+}, function($ctx1) {$ctx1.fill(self,"browseIt",{})});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "browseIt\x0a\x09| result |\x0a\x09\x0a\x09result := [ self doIt ] on: Error do: [ :exception | \x0a\x09\x09^ ErrorHandler handleError: exception ].\x0a\x09\x09\x0a\x09self model browse: result",
-referencedClasses: ["Error", "ErrorHandler"],
+source: "browseIt\x0a\x09[ self model browse: self basicDoIt ] fork",
+referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["on:do:", "doIt", "handleError:", "browse:", "model"]
+messageSends: ["fork", "browse:", "model", "basicDoIt"]
 }),
 $globals.HLCodeWidget);
 
@@ -576,29 +577,30 @@ selector: "doIt",
 protocol: "actions",
 fn: function (){
 var self=this,$self=this;
-var result;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
-$1=$self._model();
+$recv((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["model"]=1;
+return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
-result=$recv($1)._doIt_($self._currentLineOrSelection());
-$recv($recv($self._model())._announcer())._announce_($recv($globals.HLDoItExecuted)._on_($self.model));
-return result;
+return $self._basicDoIt();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"doIt",{result:result})});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}))._fork();
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"doIt",{})});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "doIt\x0a\x09| result |\x0a\x0a\x09result := self model doIt: self currentLineOrSelection.\x0a\x09self model announcer announce: (HLDoItExecuted on: model).\x0a\x0a\x09^ result",
-referencedClasses: ["HLDoItExecuted"],
+source: "doIt\x0a\x09[ self basicDoIt ] fork",
+referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["doIt:", "model", "currentLineOrSelection", "announce:", "announcer", "on:"]
+messageSends: ["fork", "basicDoIt"]
 }),
 $globals.HLCodeWidget);
 
@@ -727,7 +729,15 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$recv($self._model())._inspect_($self._doIt());
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv($self._model())._inspect_($self._basicDoIt());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}))._fork();
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"inspectIt",{})});
@@ -735,11 +745,11 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "inspectIt\x0a\x09self model inspect: self doIt",
+source: "inspectIt\x0a\x09[ self model inspect: self basicDoIt ] fork",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["inspect:", "model", "doIt"]
+messageSends: ["fork", "inspect:", "model", "basicDoIt"]
 }),
 $globals.HLCodeWidget);
 
@@ -1135,7 +1145,15 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$self._print_($recv($self._doIt())._printString());
+$recv((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $self._print_($recv($self._basicDoIt())._printString());
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
+//>>excludeEnd("ctx");
+}))._fork();
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"printIt",{})});
@@ -1143,11 +1161,11 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "printIt\x0a\x09self print: self doIt printString",
+source: "printIt\x0a\x09[ self print: self basicDoIt printString ] fork",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["print:", "printString", "doIt"]
+messageSends: ["fork", "print:", "printString", "basicDoIt"]
 }),
 $globals.HLCodeWidget);
 

+ 14 - 26
src/Helios-Workspace.st

@@ -33,18 +33,7 @@ browse: anObject
 !
 
 doIt: aString
-	"Evaluate aString in the receiver's `environment`.
-	
-	Note: Catch any error and handle it manually, bypassing
-	boot.js behavior to avoid the browser default action on
-	ctrl+d/ctrl+p.
-	
-	See https://lolg.it/amber/amber/issues/882"
-
-	^ [ self environment evaluate: aString for: self receiver ]
-		tryCatch: [ :e | 
-			ErrorHandler handleError: e.
-			nil ]
+	^ self environment evaluate: aString for: self receiver
 !
 
 inspect: anObject
@@ -149,13 +138,17 @@ selectionStart: anInteger
 
 !HLCodeWidget methodsFor: 'actions'!
 
-browseIt
+basicDoIt
 	| result |
-	
-	result := [ self doIt ] on: Error do: [ :exception | 
-		^ ErrorHandler handleError: exception ].
-		
-	self model browse: result
+
+	result := self model doIt: self currentLineOrSelection.
+	self model announcer announce: (HLDoItExecuted on: model).
+
+	^ result
+!
+
+browseIt
+	[ self model browse: self basicDoIt ] fork
 !
 
 clear
@@ -177,12 +170,7 @@ configureEditor
 !
 
 doIt
-	| result |
-
-	result := self model doIt: self currentLineOrSelection.
-	self model announcer announce: (HLDoItExecuted on: model).
-
-	^ result
+	[ self basicDoIt ] fork
 !
 
 editor
@@ -194,7 +182,7 @@ focus
 !
 
 inspectIt
-	self model inspect: self doIt
+	[ self model inspect: self basicDoIt ] fork
 !
 
 navigateTo: aString
@@ -227,7 +215,7 @@ print: aString
 !
 
 printIt
-	self print: self doIt printString
+	[ self print: self basicDoIt printString ] fork
 !
 
 saveIt