Browse Source

HUE-4279 [editor] Shrink back the editor if the query is not big enough and it hasn't been resized manually

Enrico Berti 9 years ago
parent
commit
76008b0
1 changed files with 8 additions and 0 deletions
  1. 8 0
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

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

@@ -1449,6 +1449,7 @@
       ace().on('change', function () {
         if (autoExpand) {
           var maxAutoLines = Math.floor((($(window).height() - 80) / 2) / 16);
+          var resized = false;
           if (ace().session.getLength() > editorHeight) {
             if (ace().session.getLength() < maxAutoLines) {
               $target.height((ace().session.getLength() + 1) * 16);
@@ -1456,6 +1457,13 @@
             else {
               $target.height(maxAutoLines * 16); // height of maxAutoLines
             }
+            resized = true;
+          }
+          else if (ace().session.getLength() > 8) {
+            $target.height((ace().session.getLength()) * 16);
+            resized = true;
+          }
+          if (resized) {
             ace().resize();
             editorHeight = ace().session.getLength();
             huePubSub.publish('redraw.fixed.headers');