Ver Fonte

Fixbug: it shows incorrect error line num when we only query selected
SQL

Fred Liang há 8 anos atrás
pai
commit
30fca7ed17
1 ficheiros alterados com 13 adições e 3 exclusões
  1. 13 3
      app/views/blazer/queries/_form.html.erb

+ 13 - 3
app/views/blazer/queries/_form.html.erb

@@ -106,6 +106,18 @@
     return text.replace(/\n/g, "\r\n");
   }
 
+  function getErrorLine() {
+    var error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
+
+    if (error_line) {
+      error_line = parseInt(error_line[1], 10);
+      if (editor.getSelectedText().length > 0) {
+        error_line += editor.getSelectionRange().start.row;
+      }
+      return error_line;
+    }
+  }
+
   editor.getSession().on("change", adjustHeight);
   adjustHeight();
   $("#editor").show();
@@ -133,10 +145,8 @@
     xhr = runQuery(data, function (data) {
       $("#results").html(data);
 
-      error_line = /LINE (\d+)/g.exec($("#results").find('.alert-danger').text());
-
+      error_line = getErrorLine();
       if (error_line) {
-        error_line = parseInt(error_line[1], 10);
         editor.getSession().addGutterDecoration(error_line - 1, "error");
         editor.scrollToLine(error_line, true, true, function () {});
         editor.gotoLine(error_line, 0, true);