浏览代码

HUE-6219 [editor] Mark the active statement in the gutter

Johan Ahlen 8 年之前
父节点
当前提交
40a9183

文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


文件差异内容过多而无法显示
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


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

@@ -3502,6 +3502,7 @@
             }
           }
 
+
           var lastKnownLocations = { id: $el.attr("id"), type: snippet.type(), defaultDatabase: snippet.database(), locations: e.data.locations };
 
           // Clear out old parse locations to prevent them from being shown when there's a syntax error in the statement

+ 8 - 0
desktop/core/src/desktop/static/desktop/less/hue-cross-version.less

@@ -190,6 +190,14 @@ input[type='password']::-ms-reveal {
   margin-top: -1px;
 }
 
+.ace_gutter-cell {
+  border-right: 1px solid transparent;
+  &.ace-active-gutter-decoration {
+    background-color: @hue-primary-color-light !important;
+    border-right: 1px solid @hue-primary-color-dark;
+  }
+}
+
 .card {
   background-color: @cui-white;
 }

+ 22 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -1812,13 +1812,34 @@ from notebook.conf import get_ordered_interpreters
         };
 
         var AceRange = ace.require('ace/range').Range;
+        var lastMarkedGutterLines = [];
         var findStatementTextAtCursor = function () {
           if (!self.activeStatementLocation() || !self.activeCursorLocation()) {
             return; // undefined when unknown
           }
           var statementLoc = self.activeStatementLocation();
+
           var editor = self.activeCursorLocation().editor;
-          return editor.session.getTextRange(new AceRange(statementLoc.first_line - 1, statementLoc.first_column - 1, statementLoc.last_line - 1, statementLoc.last_column - 1))
+          var statementAtCursor = editor.session.getTextRange(new AceRange(statementLoc.first_line - 1, statementLoc.first_column - 1, statementLoc.last_line - 1, statementLoc.last_column - 1));
+
+          var leadingEmptyLineCount = 0;
+          var leadingWhiteSpace = statementAtCursor.match(/^\s+/);
+          if (leadingWhiteSpace) {
+            var lineBreakMatch = leadingWhiteSpace[0].match(/^(\r\n)|(\n)|(\r)/g);
+            if (lineBreakMatch) {
+              leadingEmptyLineCount = lineBreakMatch.length;
+            }
+          }
+
+          while(lastMarkedGutterLines.length) {
+            editor.session.removeGutterDecoration(lastMarkedGutterLines.shift(), 'ace-active-gutter-decoration');
+          }
+          for (var line = statementLoc.first_line - 1 + leadingEmptyLineCount; line < statementLoc.last_line; line ++) {
+            lastMarkedGutterLines.push(line);
+            editor.session.addGutterDecoration(line, 'ace-active-gutter-decoration');
+          }
+
+          return editor.session.getTextRange(new AceRange(statementLoc.first_line - 1, statementLoc.first_column - 1, statementLoc.last_line - 1, statementLoc.last_column - 1));
         };
 
         self.disposals.push(huePubSub.subscribe('get.active.editor.statement', function () {

部分文件因为文件数量过多而无法显示