From b7a495cdb80dd0285f8e915cf805bf4ce930abeb Mon Sep 17 00:00:00 2001 From: aamunger Date: Tue, 4 Apr 2023 16:03:10 -0700 Subject: [PATCH] adjust output truncation message --- .../notebook-renderers/src/textHelper.ts | 48 ++++++++++--------- .../notebook/browser/notebook.contribution.ts | 6 +-- .../preferences/browser/settingsEditor2.ts | 1 + 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/extensions/notebook-renderers/src/textHelper.ts b/extensions/notebook-renderers/src/textHelper.ts index 99edbf8465c..86bc7c3ec93 100644 --- a/extensions/notebook-renderers/src/textHelper.ts +++ b/extensions/notebook-renderers/src/textHelper.ts @@ -8,36 +8,37 @@ import { handleANSIOutput } from './ansi'; export const scrollableClass = 'scrollable'; function generateViewMoreElement(outputId: string) { + // Output is Truncated. View as a [scrollable element] or open in a [text editor]. Output layout settings const container = document.createElement('div'); const first = document.createElement('span'); - first.textContent = 'Output exceeds the '; - - const second = document.createElement('a'); - second.textContent = 'size limit'; - second.href = `command:workbench.action.openSettings?%5B%22notebook.output.textLineLimit%22%5D`; + first.textContent = 'Output is Truncated. View as a '; container.appendChild(first); + + const viewAsScrollableLink = document.createElement('a'); + viewAsScrollableLink.textContent = 'scrollable element'; + viewAsScrollableLink.href = `command:cellOutput.enableScrolling?${outputId}`; + viewAsScrollableLink.ariaLabel = 'enable scrollable output'; + container.appendChild(viewAsScrollableLink); + + const second = document.createElement('span'); + second.textContent = ' or open in a '; container.appendChild(second); + const openInTextEditorLink = document.createElement('a'); + openInTextEditorLink.textContent = 'text editor'; + openInTextEditorLink.href = `command:workbench.action.openLargeOutput?${outputId}`; + openInTextEditorLink.ariaLabel = 'open output in text editor'; + container.appendChild(openInTextEditorLink); + const third = document.createElement('span'); - third.textContent = '. Open the full output data '; - - const forth = document.createElement('a'); - forth.textContent = 'in a text editor'; - forth.href = `command:workbench.action.openLargeOutput?${outputId}`; + third.textContent = '. Adjust '; container.appendChild(third); - container.appendChild(forth); - const refreshSpan = document.createElement('span'); - refreshSpan.classList.add('scroll-refresh'); - const fifth = document.createElement('span'); - fifth.textContent = ', or view in a '; - - const sixth = document.createElement('a'); - sixth.textContent = 'scrollable element'; - sixth.href = `command:cellOutput.enableScrolling?${outputId}`; - refreshSpan.appendChild(fifth); - refreshSpan.appendChild(sixth); - container.appendChild(refreshSpan); + const layoutSettingsLink = document.createElement('a'); + layoutSettingsLink.textContent = 'settings...'; + layoutSettingsLink.href = `command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D`; + layoutSettingsLink.ariaLabel = 'notebook output settings'; + container.appendChild(layoutSettingsLink); return container; } @@ -66,7 +67,6 @@ function truncatedArrayOfString(id: string, buffer: string[], linesLimit: number return container; } - container.appendChild(generateViewMoreElement(id)); container.appendChild(handleANSIOutput(buffer.slice(0, linesLimit - 5).join('\n'), trustHtml)); // truncated piece @@ -76,6 +76,8 @@ function truncatedArrayOfString(id: string, buffer: string[], linesLimit: number container.appendChild(handleANSIOutput(buffer.slice(lineCount - 5).join('\n'), trustHtml)); + container.appendChild(generateViewMoreElement(id)); + return container; } diff --git a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts index 02a40f9eefc..d157a0a1a61 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts @@ -862,7 +862,7 @@ configurationRegistry.registerConfiguration({ markdownDescription: nls.localize('notebook.textOutputLineLimit', "Controls how many lines of text are displayed in a text output. If {0} is enabled, this setting is used to determine the scroll height of the output.", '`#notebook.output.scrolling#`'), type: 'number', default: 30, - tags: ['notebookLayout'] + tags: ['notebookLayout', 'notebookOutputLayout'] }, [NotebookSetting.markupFontSize]: { markdownDescription: nls.localize('notebook.markup.fontSize', "Controls the font size in pixels of rendered markup in notebooks. When set to {0}, 120% of {1} is used.", '`0`', '`#editor.fontSize#`'), @@ -897,13 +897,13 @@ configurationRegistry.registerConfiguration({ [NotebookSetting.outputScrolling]: { markdownDescription: nls.localize('notebook.outputScrolling', "Use a scrollable region for notebook output when longer than the limit"), type: 'boolean', - tags: ['notebookLayout'], + tags: ['notebookLayout', 'notebookOutputLayout'], default: typeof product.quality === 'string' && product.quality !== 'stable' // only enable as default in insiders }, [NotebookSetting.outputWordWrap]: { markdownDescription: nls.localize('notebook.outputWordWrap', "Controls whether the lines in output should wrap."), type: 'boolean', - tags: ['notebookLayout'], + tags: ['notebookLayout', 'notebookOutputLayout'], default: false }, [NotebookSetting.formatOnSave]: { diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts index d7a171f36ee..cfbf75dadff 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditor2.ts @@ -109,6 +109,7 @@ export class SettingsEditor2 extends EditorPane { private static SUGGESTIONS: string[] = [ `@${MODIFIED_SETTING_TAG}`, '@tag:notebookLayout', + '@tag:notebookOutputLayout', `@tag:${REQUIRE_TRUSTED_WORKSPACE_SETTING_TAG}`, `@tag:${WORKSPACE_TRUST_SETTING_TAG}`, '@tag:sync',