Parcourir la source

HUE-4412 [editor] Errors should scroll to the line AND the column too

Enrico Berti il y a 9 ans
Parent
commit
3d46a4c

+ 3 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -2621,6 +2621,9 @@
               editor.addError(err.message, err.line + offset);
               if (cnt == 0) {
                 editor.scrollToLine(err.line + offset, true, true, function () {});
+                if (err.col !== null){
+                  editor.renderer.scrollCursorIntoView({row: err.line + offset, column: err.col + 10}, 0.5)
+                }
               }
             }
           });

+ 3 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -206,7 +206,7 @@
     return properties;
   };
 
-  var ERROR_REGEX = /line ([0-9]+)/i;
+  var ERROR_REGEX = /line ([0-9]+)(\:([0-9]+))?/i;
 
   var Snippet = function (vm, notebook, snippet) {
     var self = this;
@@ -680,7 +680,8 @@
         var match = ERROR_REGEX.exec(data.message);
         self.errors.push({
           message: data.message,
-          line: match === null ? null : parseInt(match[1]) - 1
+          line: match === null ? null : parseInt(match[1]) - 1,
+          col: match === null ? null : (typeof match[3] !== 'undefined' ? parseInt(match[3]) : null)
         });
       } else {
         $(document).trigger("error", data.message);