From c6033399d0a00cc906d23fa3d2e9a1208b1c7ae8 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 18 Oct 2019 18:28:59 -0400 Subject: [PATCH 1/2] Fix off-by-one errors --- awx/ui/client/features/output/render.service.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/features/output/render.service.js b/awx/ui/client/features/output/render.service.js index 161aebceb3..11d7108cd0 100644 --- a/awx/ui/client/features/output/render.service.js +++ b/awx/ui/client/features/output/render.service.js @@ -473,7 +473,7 @@ function JobRenderService ($q, $compile, $sce, $window) { this.shift = lines => { // We multiply by two here under the assumption that one element and one text node // is generated for each line of output. - const count = 2 * lines; + const count = (2 * lines) + 1; const elements = this.el.contents().slice(0, count); return this.remove(elements); @@ -482,7 +482,7 @@ function JobRenderService ($q, $compile, $sce, $window) { this.pop = lines => { // We multiply by two here under the assumption that one element and one text node // is generated for each line of output. - const count = 2 * lines; + const count = (2 * lines) + 1; const elements = this.el.contents().slice(-count); return this.remove(elements); @@ -558,7 +558,7 @@ function JobRenderService ($q, $compile, $sce, $window) { } const max = this.state.tail; - const min = max - count; + const min = max - count + 1; let lines = 0; @@ -589,7 +589,7 @@ function JobRenderService ($q, $compile, $sce, $window) { } const min = this.state.head; - const max = min + count; + const max = min + count - 1; let lines = 0; From 312cf137777ea1a960d1394b8d4fad84fc015a99 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 18 Oct 2019 18:44:06 -0400 Subject: [PATCH 2/2] Set omitted runner event line lengths to 0 runner_on_start events have zero-length strings for their stdout fields. We don't want to display these in the ui so we omit them. Although the stdout field is an empty string, it still has a recorded line length of 1 that we must account for. Since we're not rendering the blank line, we must also go back and set the event record's line length to 0 in order to avoid deleting too many lines when we pop or shift events off of the view while scrolling. --- awx/ui/client/features/output/render.service.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/awx/ui/client/features/output/render.service.js b/awx/ui/client/features/output/render.service.js index 11d7108cd0..3dad042aa4 100644 --- a/awx/ui/client/features/output/render.service.js +++ b/awx/ui/client/features/output/render.service.js @@ -213,6 +213,18 @@ function JobRenderService ($q, $compile, $sce, $window) { const record = this.createRecord(event, lines); if (lines.length === 1 && lines[0] === '') { + // Some events, mainly runner_on_start events, have an actual line count of 1 + // (stdout = '') and a claimed line count of 0 (end_line - start_line = 0). + // Since a zero-length string has an actual line count of 1, they'll still get + // rendered as blank lines unless we intercept them and add some special + // handling to remove them. + // + // Although we're not going to render the blank line, the actual line count of + // the zero-length stdout string, which is 1, has already been recorded at this + // point so we must also go back and set the event's recorded line length to 0 + // in order to avoid deleting too many lines when we need to pop or shift a + // page that contains this event off of the view. + this.records[record.uuid].lineCount = 0; return { html: '', count: 0 }; }