From 78e417add4ce575f3ff7cf5d5e6c3377b2f8a205 Mon Sep 17 00:00:00 2001 From: mattpass Date: Sun, 25 Apr 2021 08:32:36 +0100 Subject: [PATCH] Limit tooltip func arg list to 200 chars, wrap in terminal --- assets/css/terminal.css | 2 +- assets/js/icecoder.js | 8 ++++++-- lib/indexer.php | 7 ++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/assets/css/terminal.css b/assets/css/terminal.css index 7cecec9..2f44b39 100644 --- a/assets/css/terminal.css +++ b/assets/css/terminal.css @@ -27,7 +27,7 @@ table, caption, tbody, tfoot, thead, tr, th, td { html, body {width: 100%; height: 100%} -.output {position: absolute; display: block; top: 0; padding: 15px 18px 8px 13px; width: 100%; min-height: 100%; border: 0; background: rgba(0,0,0,0.92); color: #ccc} +.output {position: absolute; display: block; top: 0; padding: 15px 18px 8px 13px; width: 100%; min-height: 100%; border: 0; background: rgba(0,0,0,0.92); color: #ccc; white-space: pre-wrap; word-break: break-all} .commandLine {width: 100%; padding: 8px 2px 8px 0; color: #fff} .commandLine .user {display: inline-block; height: 24px; margin-top: -4px; margin-left: -13px; padding: 5px 5px 5px 0; margin-bottom: 5px; background: #b58901; color: #000} .commandLine .cwd {display: inline-block; height: 24px; margin-top: -4px; padding: 5px 5px 5px 0; margin-bottom: 5px; background: #278bd2; color: #fff} diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index 9ba5d45..1f7c815 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -761,7 +761,7 @@ var ICEcoder = { // If we have a single result and the mouse pointer is not over the definition of it (that would be pointless), show tooltip if (1 === numResults && -1 === [null, "def"].indexOf(cM.getTokenTypeAt(coordsChar))) { get('tooltip').style.display = "block"; - get('tooltip').style.left = (this.mouseX - this.maxFilesW + 10) + "px"; + get('tooltip').style.left = (this.mouseX + 10) + "px"; numLintErrors = this.content.contentWindow.document.getElementsByClassName("CodeMirror-lint-tooltip")[0]; numLintErrors = numLintErrors && numLintErrors.childNodes ? numLintErrors.childNodes.length @@ -771,7 +771,11 @@ var ICEcoder = { ? 18 * numLintErrors : 0) ) + "px"; - get('tooltip').style.zIndex = "1"; + get('tooltip').style.zIndex = 1000; + // Limit function args list to 200 char max + if (result.params.length > 200) { + result.params = result.params.substr(0, 200) + "...)"; + } get('tooltip').innerHTML = result.params; // Else hide it } else { diff --git a/lib/indexer.php b/lib/indexer.php index 12a589d..7785abf 100644 --- a/lib/indexer.php +++ b/lib/indexer.php @@ -19,7 +19,7 @@ if (file_exists($docRoot . $ICEcoderDir . "/data/index.php")) { } // Roughly 1 in 100 index runs, we'll do a full index -if (mt_rand(1,100) === 50) { +if (mt_rand(1, 100) === 50) { $prevIndexData = []; } @@ -119,6 +119,11 @@ function phpGrep($path, $base) { $functionArgs = str_replace('=', ' = ', $functionArgs); $functionArgs = preg_replace('/\s+/', ' ', $functionArgs); + // Limit function args list to 200 char max + if (strlen($functionArgs) > 200) { + $functionArgs = substr($functionArgs, 0, 200) . "...)"; + } + // Finally, we have our function name and args $functionText = [ 0 => $functionName,