diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bf79c531..065eb9672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,14 @@ Code style revamp! We reworked how routines, routine methods, properties, and st - When generating ENVI and IDL tasks, using our new case libraries, we attempt to make a pretty display name from parameter names. For example converting the keyword "my_keyword" to "My Keyword". This applied to task and parameter display names. +## 4.2.2 December 2023 + +Resolved a performance issue with notebooks where auto-complete and hover help would take a while to return if you have been making many edits in a short amount of time + +Fixed an issue with semantic tokens not showing up like they should. + +Tweaked the styling for PDF generation to have output cells look a little different than input. + ## 4.2.1 December 2023 Fixed an issue where logs were sharing too much information and other logs were not properly reporting diff --git a/apps/client-e2e/src/tests/debugging/breakpoint-step-in-step-out.ts b/apps/client-e2e/src/tests/debugging/breakpoint-step-in-step-out.ts index 3403e1a1d..5a87b2b86 100644 --- a/apps/client-e2e/src/tests/debugging/breakpoint-step-in-step-out.ts +++ b/apps/client-e2e/src/tests/debugging/breakpoint-step-in-step-out.ts @@ -77,13 +77,4 @@ export const BreakPointStepInStepOut: RunnerFunction = async (init) => { // reset await init.debug.adapter.evaluate('.reset'); - - // close editor - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(DEBUG_PAUSE); - - // verify we cleaned up - expect(GetActivePROCodeWindow(false)).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/debugging/compile.ts b/apps/client-e2e/src/tests/debugging/compile.ts index 4679b125d..3627bd96f 100644 --- a/apps/client-e2e/src/tests/debugging/compile.ts +++ b/apps/client-e2e/src/tests/debugging/compile.ts @@ -1,7 +1,7 @@ import { CleanIDLOutput } from '@idl/idl'; import { IDL_COMMANDS } from '@idl/shared'; import { Sleep } from '@idl/test-helpers'; -import { GetActivePROCodeWindow, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { GetActivePROCodeWindow } from '@idl/vscode/shared'; import expect from 'expect'; import * as vscode from 'vscode'; @@ -42,13 +42,4 @@ export const Compile: RunnerFunction = async (init) => { // make sure it is the plot file expect(editor.uri.fsPath.endsWith('plot.pro')).toBeTruthy(); - - // close editor - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(DEBUG_PAUSE); - - // verify we cleaned up - expect(GetActivePROCodeWindow(false)).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/debugging/continue.ts b/apps/client-e2e/src/tests/debugging/continue.ts index 18fc0436b..352b3ca80 100644 --- a/apps/client-e2e/src/tests/debugging/continue.ts +++ b/apps/client-e2e/src/tests/debugging/continue.ts @@ -72,13 +72,4 @@ export const Continue: RunnerFunction = async (init) => { // wait a little bit await Sleep(DEBUG_PAUSE); } - - // close editor - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(DEBUG_PAUSE); - - // verify we cleaned up - expect(GetActivePROCodeWindow(false)).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/debugging/edit.ts b/apps/client-e2e/src/tests/debugging/edit.ts index 4a416ca60..a199ec7da 100644 --- a/apps/client-e2e/src/tests/debugging/edit.ts +++ b/apps/client-e2e/src/tests/debugging/edit.ts @@ -1,6 +1,6 @@ import { IDL_COMMANDS } from '@idl/shared'; import { Sleep } from '@idl/test-helpers'; -import { GetActivePROCodeWindow, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { GetActivePROCodeWindow } from '@idl/vscode/shared'; import expect from 'expect'; import * as vscode from 'vscode'; @@ -36,13 +36,4 @@ export const Edit: RunnerFunction = async (init) => { // make sure it is the plot file expect(editor.uri.fsPath.endsWith('plot.pro')).toBeTruthy(); - - // close editor - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(DEBUG_PAUSE); - - // verify we cleaned up - expect(GetActivePROCodeWindow(false)).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/interactions/_interactions-runner.ts b/apps/client-e2e/src/tests/interactions/_interactions-runner.ts index 5baf60aa1..9523449e0 100644 --- a/apps/client-e2e/src/tests/interactions/_interactions-runner.ts +++ b/apps/client-e2e/src/tests/interactions/_interactions-runner.ts @@ -4,9 +4,10 @@ import { Runner } from '../runner.class'; import { AddDocs } from './add-docs'; import { IDLJSONInteractRight } from './idl-json-interact-right'; import { IndexIDLFolderRightAndOpenEditClose } from './index-idl-folder-right-and-open-edit-close'; +import { NotebookProblemsTrackRight } from './notebook-problems-track-right'; import { NotebookCompletionBasic } from './notebooks-completion-basic'; import { NotebooksInteractRight } from './notebooks-interact-right'; -import { NotebooksNoDuplicates } from './notebooks-no-duplicates'; +import { NotebooksNoDuplicateRoutines } from './notebooks-no-duplicate-routines'; import { ProCodeInteractRight } from './pro-code-interacts-right'; import { TasksInteractRight } from './tasks-interact-right'; @@ -56,8 +57,8 @@ INTERACTIONS_RUNNER.addTest({ }); INTERACTIONS_RUNNER.addTest({ - name: 'Notebook problems track right', - fn: NotebooksNoDuplicates, + name: 'No duplicate routine definition problems', + fn: NotebooksNoDuplicateRoutines, }); INTERACTIONS_RUNNER.addTest({ @@ -65,3 +66,9 @@ INTERACTIONS_RUNNER.addTest({ fn: NotebookCompletionBasic, critical: true, }); + +// notebook problems track right +INTERACTIONS_RUNNER.addTest({ + name: 'Notebook problems track right', + fn: NotebookProblemsTrackRight, +}); diff --git a/apps/client-e2e/src/tests/interactions/add-docs.ts b/apps/client-e2e/src/tests/interactions/add-docs.ts index 3259ae5f4..22632b518 100644 --- a/apps/client-e2e/src/tests/interactions/add-docs.ts +++ b/apps/client-e2e/src/tests/interactions/add-docs.ts @@ -1,9 +1,5 @@ import { GetExtensionPath, IDL_COMMANDS, Sleep } from '@idl/shared'; -import { - OpenFileInVSCode, - ReplaceDocumentContent, - VSCODE_COMMANDS, -} from '@idl/vscode/shared'; +import { OpenFileInVSCode, ReplaceDocumentContent } from '@idl/vscode/shared'; import expect from 'expect'; import { readFileSync } from 'fs'; import * as vscode from 'vscode'; @@ -60,7 +56,4 @@ export const AddDocs: RunnerFunction = async (init) => { 'utf-8' ) ); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/interactions/idl-json-interact-right.ts b/apps/client-e2e/src/tests/interactions/idl-json-interact-right.ts index 008a321bb..64968613c 100644 --- a/apps/client-e2e/src/tests/interactions/idl-json-interact-right.ts +++ b/apps/client-e2e/src/tests/interactions/idl-json-interact-right.ts @@ -1,9 +1,5 @@ import { GetExtensionPath, Sleep } from '@idl/shared'; -import { - OpenFileInVSCode, - ReplaceDocumentContent, - VSCODE_COMMANDS, -} from '@idl/vscode/shared'; +import { OpenFileInVSCode, ReplaceDocumentContent } from '@idl/vscode/shared'; import expect from 'expect'; import { readFileSync } from 'fs'; import * as vscode from 'vscode'; @@ -76,10 +72,4 @@ export const IDLJSONInteractRight: RunnerFunction = async (init) => { 'textDocument/semanticTokens/full', tokenParams ); - - // short pause - await Sleep(250); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/notebook-problems-track-right.ts b/apps/client-e2e/src/tests/interactions/notebook-problems-track-right.ts similarity index 86% rename from apps/client-e2e/src/tests/notebooks/notebook-problems-track-right.ts rename to apps/client-e2e/src/tests/interactions/notebook-problems-track-right.ts index 4e4e6fc3f..31defe2b6 100644 --- a/apps/client-e2e/src/tests/notebooks/notebook-problems-track-right.ts +++ b/apps/client-e2e/src/tests/interactions/notebook-problems-track-right.ts @@ -1,5 +1,5 @@ import { GetExtensionPath, Sleep } from '@idl/shared'; -import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { OpenNotebookInVSCode } from '@idl/vscode/shared'; import expect from 'expect'; import * as vscode from 'vscode'; @@ -47,7 +47,4 @@ export const NotebookProblemsTrackRight: RunnerFunction = async (init) => { .getCells() .map((cell) => vscode.languages.getDiagnostics(cell.document.uri).length) ).toEqual([0, 3]); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/interactions/notebooks-completion-basic.ts b/apps/client-e2e/src/tests/interactions/notebooks-completion-basic.ts index cada6a9bc..9727e1566 100644 --- a/apps/client-e2e/src/tests/interactions/notebooks-completion-basic.ts +++ b/apps/client-e2e/src/tests/interactions/notebooks-completion-basic.ts @@ -1,7 +1,6 @@ import { GetExtensionPath, Sleep } from '@idl/shared'; -import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { OpenNotebookInVSCode } from '@idl/vscode/shared'; import expect from 'expect'; -import * as vscode from 'vscode'; import { CompletionItem as LanguageServerCompletionItem, TextDocumentPositionParams, @@ -67,7 +66,4 @@ export const NotebookCompletionBasic: RunnerFunction = async (init) => { // verify definition has return expect(completion2).toStrictEqual(expect.any(Array)); expect(completion2.length).not.toEqual(0); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/interactions/notebooks-interact-right.ts b/apps/client-e2e/src/tests/interactions/notebooks-interact-right.ts index 0a4c53b0e..3f2ba01af 100644 --- a/apps/client-e2e/src/tests/interactions/notebooks-interact-right.ts +++ b/apps/client-e2e/src/tests/interactions/notebooks-interact-right.ts @@ -1,8 +1,8 @@ -import { GetExtensionPath, Sleep } from '@idl/shared'; -import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { GetExtensionPath } from '@idl/shared'; +import { OpenNotebookInVSCode } from '@idl/vscode/shared'; import expect from 'expect'; -import * as vscode from 'vscode'; import { + SemanticTokens, SemanticTokensParams, TextDocumentPositionParams, } from 'vscode-languageserver'; @@ -83,17 +83,13 @@ export const NotebooksInteractRight: RunnerFunction = async (init) => { }, }; - // verify semantic tokens (have none in NB, so get none) + // verify semantic tokens expect( - await init.client.client.sendRequest( - 'textDocument/semanticTokens/full', - tokenParams - ) - ).toEqual({ data: [] }); - - // short pause - await Sleep(250); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); + ( + (await init.client.client.sendRequest( + 'textDocument/semanticTokens/full', + tokenParams + )) as SemanticTokens + ).data + ).toEqual([8, 0, 11, 0, 0]); }; diff --git a/apps/client-e2e/src/tests/interactions/notebooks-no-duplicates.ts b/apps/client-e2e/src/tests/interactions/notebooks-no-duplicate-routines.ts similarity index 87% rename from apps/client-e2e/src/tests/interactions/notebooks-no-duplicates.ts rename to apps/client-e2e/src/tests/interactions/notebooks-no-duplicate-routines.ts index 05254f91d..13a70202a 100644 --- a/apps/client-e2e/src/tests/interactions/notebooks-no-duplicates.ts +++ b/apps/client-e2e/src/tests/interactions/notebooks-no-duplicate-routines.ts @@ -8,13 +8,13 @@ import { RunnerFunction } from '../runner.interface'; /** * Verifies */ -export const NotebooksNoDuplicates: RunnerFunction = async (init) => { +export const NotebooksNoDuplicateRoutines: RunnerFunction = async (init) => { const doc = await OpenNotebookInVSCode( GetExtensionPath('idl/test/client-e2e/notebooks/problems-before.idlnb') ); // short pause - await Sleep(250); + await Sleep(500); /** * Get first cell which is code @@ -30,13 +30,13 @@ export const NotebooksNoDuplicates: RunnerFunction = async (init) => { await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_FOCUS_TOP); // short pause - await Sleep(250); + await Sleep(500); // delete the first cell await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_CELL_DELETE); // short pause - await Sleep(250); + await Sleep(500); /** * Get first cell which is code @@ -57,7 +57,7 @@ export const NotebooksNoDuplicates: RunnerFunction = async (init) => { ); // short pause - await Sleep(250); + await Sleep(500); /** * Get second cell again @@ -73,7 +73,4 @@ export const NotebooksNoDuplicates: RunnerFunction = async (init) => { // verify problems expect(nAfterRound2).toEqual(nOrig); - - // close - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/interactions/pro-code-interacts-right.ts b/apps/client-e2e/src/tests/interactions/pro-code-interacts-right.ts index ebaf36e26..cb1e03d80 100644 --- a/apps/client-e2e/src/tests/interactions/pro-code-interacts-right.ts +++ b/apps/client-e2e/src/tests/interactions/pro-code-interacts-right.ts @@ -1,8 +1,8 @@ -import { GetExtensionPath, Sleep } from '@idl/shared'; -import { OpenFileInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { GetExtensionPath } from '@idl/shared'; +import { OpenFileInVSCode } from '@idl/vscode/shared'; import expect from 'expect'; -import * as vscode from 'vscode'; import { + SemanticTokens, SemanticTokensParams, TextDocumentPositionParams, } from 'vscode-languageserver'; @@ -76,17 +76,13 @@ export const ProCodeInteractRight: RunnerFunction = async (init) => { }, }; - // verify semantic tokens (have none in code, so get none) + // verify semantic tokens expect( - await init.client.client.sendRequest( - 'textDocument/semanticTokens/full', - tokenParams - ) - ).toEqual({ data: [] }); - - // short pause - await Sleep(250); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); + ( + (await init.client.client.sendRequest( + 'textDocument/semanticTokens/full', + tokenParams + )) as SemanticTokens + ).data + ).toEqual([10, 0, 11, 0, 0]); }; diff --git a/apps/client-e2e/src/tests/interactions/tasks-interact-right.ts b/apps/client-e2e/src/tests/interactions/tasks-interact-right.ts index 65ac2b621..b520e28be 100644 --- a/apps/client-e2e/src/tests/interactions/tasks-interact-right.ts +++ b/apps/client-e2e/src/tests/interactions/tasks-interact-right.ts @@ -1,9 +1,5 @@ import { GetExtensionPath, Sleep } from '@idl/shared'; -import { - OpenFileInVSCode, - ReplaceDocumentContent, - VSCODE_COMMANDS, -} from '@idl/vscode/shared'; +import { OpenFileInVSCode, ReplaceDocumentContent } from '@idl/vscode/shared'; import expect from 'expect'; import { readFileSync } from 'fs'; import * as vscode from 'vscode'; @@ -76,10 +72,4 @@ export const TasksInteractRight: RunnerFunction = async (init) => { 'textDocument/semanticTokens/full', tokenParams ); - - // short pause - await Sleep(250); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/_notebook-runner.ts b/apps/client-e2e/src/tests/notebooks/_notebook-runner.ts index 015048c73..421ef9b5e 100644 --- a/apps/client-e2e/src/tests/notebooks/_notebook-runner.ts +++ b/apps/client-e2e/src/tests/notebooks/_notebook-runner.ts @@ -4,7 +4,6 @@ import { Runner } from '../runner.class'; import { NewNotebook } from './new-notebook'; import { NotebookFormats_1_0_0 } from './notebook-formats-1.0.0'; import { NotebookFormats_2_0_0 } from './notebook-formats-2.0.0'; -import { NotebookProblemsTrackRight } from './notebook-problems-track-right'; import { RunNotebookReset } from './notebook-reset'; import { RunNotebookStop } from './notebook-stop'; import { NotebookToProCodeAllCells } from './notebook-to-pro-code-all-cells'; @@ -146,9 +145,3 @@ NOTEBOOK_RUNNER.addTest({ name: 'Verify quiet mode for notebooks', fn: VerifyQuietNotebookSetting, }); - -// notebook problems track right -NOTEBOOK_RUNNER.addTest({ - name: 'Notebook problems track right', - fn: NotebookProblemsTrackRight, -}); diff --git a/apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts b/apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts index 9d94b59a9..727fbea86 100644 --- a/apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts +++ b/apps/client-e2e/src/tests/notebooks/helpers/run-notebook-and-compare-cells.ts @@ -70,7 +70,4 @@ export async function RunNotebookAndCompareCells( // save again await nb.save(); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); } diff --git a/apps/client-e2e/src/tests/notebooks/new-notebook.ts b/apps/client-e2e/src/tests/notebooks/new-notebook.ts index dd36b485d..e8e57c357 100644 --- a/apps/client-e2e/src/tests/notebooks/new-notebook.ts +++ b/apps/client-e2e/src/tests/notebooks/new-notebook.ts @@ -1,5 +1,4 @@ import { IDL_COMMANDS, IDL_NOTEBOOK_LANGUAGE_NAME, Sleep } from '@idl/shared'; -import { VSCODE_COMMANDS } from '@idl/vscode/shared'; import expect from 'expect'; import * as vscode from 'vscode'; @@ -23,13 +22,4 @@ export const NewNotebook: RunnerFunction = async (init) => { // make sure we have an IDL Notebook as our editor expect(editor?.notebook?.notebookType).toEqual(IDL_NOTEBOOK_LANGUAGE_NAME); - - // close - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(100); - - // verify we cleaned up - expect(vscode.window.activeNotebookEditor).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/notebooks/notebook-formats-1.0.0.ts b/apps/client-e2e/src/tests/notebooks/notebook-formats-1.0.0.ts index 15257999e..1c624175f 100644 --- a/apps/client-e2e/src/tests/notebooks/notebook-formats-1.0.0.ts +++ b/apps/client-e2e/src/tests/notebooks/notebook-formats-1.0.0.ts @@ -1,5 +1,5 @@ import { GetExtensionPath } from '@idl/shared'; -import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { OpenNotebookInVSCode } from '@idl/vscode/shared'; import * as vscode from 'vscode'; import { RunnerFunction } from '../runner.interface'; @@ -90,7 +90,4 @@ export const NotebookFormats_1_0_0: RunnerFunction = async (init) => { // compare state CompareCellsAndOutputs(nb, CELL_OUTPUT); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/notebook-formats-2.0.0.ts b/apps/client-e2e/src/tests/notebooks/notebook-formats-2.0.0.ts index 0bea2c257..cf5331f15 100644 --- a/apps/client-e2e/src/tests/notebooks/notebook-formats-2.0.0.ts +++ b/apps/client-e2e/src/tests/notebooks/notebook-formats-2.0.0.ts @@ -1,5 +1,5 @@ import { GetExtensionPath } from '@idl/shared'; -import { OpenNotebookInVSCode, VSCODE_COMMANDS } from '@idl/vscode/shared'; +import { OpenNotebookInVSCode } from '@idl/vscode/shared'; import * as vscode from 'vscode'; import { RunnerFunction } from '../runner.interface'; @@ -90,7 +90,4 @@ export const NotebookFormats_2_0_0: RunnerFunction = async (init) => { // compare state CompareCellsAndOutputs(nb, CELL_OUTPUT); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/notebook-reset.ts b/apps/client-e2e/src/tests/notebooks/notebook-reset.ts index c5d0a94ad..4d959778e 100644 --- a/apps/client-e2e/src/tests/notebooks/notebook-reset.ts +++ b/apps/client-e2e/src/tests/notebooks/notebook-reset.ts @@ -61,7 +61,4 @@ export const RunNotebookReset: RunnerFunction = async (init) => { // clear outputs await vscode.commands.executeCommand(VSCODE_COMMANDS.NOTEBOOK_CLEAR_OUTPUTS); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/notebook-stop.ts b/apps/client-e2e/src/tests/notebooks/notebook-stop.ts index acfdb80ce..206e168d4 100644 --- a/apps/client-e2e/src/tests/notebooks/notebook-stop.ts +++ b/apps/client-e2e/src/tests/notebooks/notebook-stop.ts @@ -58,7 +58,4 @@ export const RunNotebookStop: RunnerFunction = async (init) => { // compare state CompareCellOutputs(nb, CELL_OUTPUT); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/open-envi-notebook-example.ts b/apps/client-e2e/src/tests/notebooks/open-envi-notebook-example.ts index b7e2effc6..b07687a8b 100644 --- a/apps/client-e2e/src/tests/notebooks/open-envi-notebook-example.ts +++ b/apps/client-e2e/src/tests/notebooks/open-envi-notebook-example.ts @@ -5,7 +5,6 @@ import { IDL_NOTEBOOK_LANGUAGE_NAME, Sleep, } from '@idl/shared'; -import { VSCODE_COMMANDS } from '@idl/vscode/shared'; import expect from 'expect'; import { join } from 'path'; import * as vscode from 'vscode'; @@ -34,13 +33,4 @@ export const OpenENVINotebookExample: RunnerFunction = async (init) => { expect(CleanPath(editor?.notebook?.uri.fsPath) || '').toEqual( join(EXAMPLE_NOTEBOOKS, 'hello-world-envi.idlnb') ); - - // close - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(100); - - // verify we cleaned up - expect(vscode.window.activeNotebookEditor).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/notebooks/open-idl-notebook-example.ts b/apps/client-e2e/src/tests/notebooks/open-idl-notebook-example.ts index c270411a2..a8c08269f 100644 --- a/apps/client-e2e/src/tests/notebooks/open-idl-notebook-example.ts +++ b/apps/client-e2e/src/tests/notebooks/open-idl-notebook-example.ts @@ -5,7 +5,6 @@ import { IDL_NOTEBOOK_LANGUAGE_NAME, Sleep, } from '@idl/shared'; -import { VSCODE_COMMANDS } from '@idl/vscode/shared'; import expect from 'expect'; import { join } from 'path'; import * as vscode from 'vscode'; @@ -32,13 +31,4 @@ export const OpenIDLNotebookExample: RunnerFunction = async (init) => { expect(CleanPath(editor?.notebook?.uri.fsPath) || '').toEqual( join(EXAMPLE_NOTEBOOKS, 'hello-world-idl.idlnb') ); - - // close - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); - - // pause momentarily - await Sleep(100); - - // verify we cleaned up - expect(vscode.window.activeNotebookEditor).toBeUndefined(); }; diff --git a/apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts b/apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts index e8fe730cf..7f6178a06 100644 --- a/apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts +++ b/apps/client-e2e/src/tests/notebooks/run-unsaved-notebook.ts @@ -69,7 +69,4 @@ export const RunUnsavedNotebook: RunnerFunction = async (init) => { // compare cells await CompareCellOutputs(nb, CELL_OUTPUT); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/notebooks/save-and-clear-output.ts b/apps/client-e2e/src/tests/notebooks/save-and-clear-output.ts index 51534d700..3c8e67e20 100644 --- a/apps/client-e2e/src/tests/notebooks/save-and-clear-output.ts +++ b/apps/client-e2e/src/tests/notebooks/save-and-clear-output.ts @@ -46,7 +46,4 @@ export const SaveAndClearNotebook: RunnerFunction = async (init) => { // save to disk await nbAfter.save(); - - // clear any existing outputs - await vscode.commands.executeCommand(VSCODE_COMMANDS.CLOSE_EDITOR); }; diff --git a/apps/client-e2e/src/tests/runner.class.ts b/apps/client-e2e/src/tests/runner.class.ts index a91fc671d..0f829788f 100644 --- a/apps/client-e2e/src/tests/runner.class.ts +++ b/apps/client-e2e/src/tests/runner.class.ts @@ -1,5 +1,6 @@ import { Logger } from '@idl/logger'; import { Sleep } from '@idl/shared'; +import * as vscode from 'vscode'; import { ACTIVATION_RESULT } from '../main'; import { IRunnerTest, TEST_PAUSE_MS } from './runner.interface'; @@ -31,6 +32,13 @@ export class Runner { this.tests.push(test); } + /** + * + */ + async closeAll() { + await vscode.commands.executeCommand('workbench.action.closeAllEditors'); + } + /** * Runs the tests that we have registered to our runner and returns the number of failures */ @@ -64,6 +72,13 @@ export class Runner { break; } } + + /** + * Close everything unless we specify that we dont + */ + if (!this.tests[i].dontCloseAll) { + await this.closeAll(); + } } return failures; diff --git a/apps/client-e2e/src/tests/runner.interface.ts b/apps/client-e2e/src/tests/runner.interface.ts index 65124c572..c758139be 100644 --- a/apps/client-e2e/src/tests/runner.interface.ts +++ b/apps/client-e2e/src/tests/runner.interface.ts @@ -17,6 +17,8 @@ export interface IRunnerTest { fn: RunnerFunction; /** If critical, this failure prevents other tests from running */ critical?: boolean; + /** Do we keep or close all editors? */ + dontCloseAll?: boolean; } /** diff --git a/apps/vscode-e2e-runner/src/main.ts b/apps/vscode-e2e-runner/src/main.ts index 59e27caa9..8184afdab 100644 --- a/apps/vscode-e2e-runner/src/main.ts +++ b/apps/vscode-e2e-runner/src/main.ts @@ -21,7 +21,6 @@ async function go() { await runTests({ extensionDevelopmentPath, extensionTestsPath, - version: '1.85.0', }); } catch (err) { console.error('Failed to run tests'); diff --git a/idl/test/client-e2e/notebooks/test-user-interaction.idlnb b/idl/test/client-e2e/notebooks/test-user-interaction.idlnb index 92370ee65..3d34793ec 100644 --- a/idl/test/client-e2e/notebooks/test-user-interaction.idlnb +++ b/idl/test/client-e2e/notebooks/test-user-interaction.idlnb @@ -10,7 +10,9 @@ " compile_opt idl2", "end", "", - "mypronbtest" + "mypronbtest", + "", + "IDLNotebook.addToNotebook" ], "metadata": {}, "outputs": [] diff --git a/idl/test/client-e2e/test_user_interaction.pro b/idl/test/client-e2e/test_user_interaction.pro index 6a2dca0a8..d7ee0acb2 100644 --- a/idl/test/client-e2e/test_user_interaction.pro +++ b/idl/test/client-e2e/test_user_interaction.pro @@ -8,4 +8,6 @@ compile_opt idl2 myproprotest +IDLNotebook.addToNotebook + end \ No newline at end of file diff --git a/libs/parsing/index/src/lib/idl-index.class.ts b/libs/parsing/index/src/lib/idl-index.class.ts index eba721a7d..37f4fedb0 100644 --- a/libs/parsing/index/src/lib/idl-index.class.ts +++ b/libs/parsing/index/src/lib/idl-index.class.ts @@ -572,7 +572,7 @@ export class IDLIndex { } } this.changedFiles[file] = true; - this.syntaxProblemsByFile[file] = problems; + this.syntaxProblemsByFile[file] = problems || []; } /** @@ -1046,7 +1046,9 @@ export class IDLIndex { this.trackSyntaxProblemsForFile(file, GetSyntaxProblems(parsed)); // save tokens for our file - this.tokensByFile.add(file, parsed); + if (!inOptions.noCache) { + this.tokensByFile.add(file, parsed); + } // return our tokens return parsed; @@ -1198,13 +1200,13 @@ export class IDLIndex { return; } - // remove notebook - await this.removeNotebook(file); - // track as known file this.knownFiles[file] = undefined; this.fileTypes['idl-notebook'].add(file); + /** Remove global tokens for cells */ + const cellUris = this.getNotebookFiles(file); + /** * Get the IDs for our workers */ @@ -1218,6 +1220,17 @@ export class IDLIndex { // parse our notebook const resp = await ParseNotebook(this, file, notebook); + /** + * Make sure we have all previous cells accounted for + * + * This handles cases where we deleted files and no longer have globals for it + */ + for (let i = 0; i < cellUris.length; i++) { + if (!(cellUris[i] in resp.globals)) { + resp.globals[cellUris[i]] = []; + } + } + // track cells as known files so we can clean up correctly next time this.trackFiles(Object.keys(resp.globals)); @@ -1247,7 +1260,7 @@ export class IDLIndex { const files = Object.keys(resp.globals); for (let i = 0; i < files.length; i++) { this.globalIndex.trackGlobalTokens(resp.globals[files[i]], files[i]); - this.trackSyntaxProblemsForFile(files[i], resp.problems[files[i]]); + this.trackSyntaxProblemsForFile(files[i], resp.problems[files[i]] || []); } // wait until synced diff --git a/libs/parsing/index/src/lib/idl-index.interface.ts b/libs/parsing/index/src/lib/idl-index.interface.ts index c0d180fa9..abfbc9158 100644 --- a/libs/parsing/index/src/lib/idl-index.interface.ts +++ b/libs/parsing/index/src/lib/idl-index.interface.ts @@ -71,6 +71,10 @@ export interface IIndexProCodeOptions extends IParserOptions { * Do change detection when we index */ changeDetection: boolean; + /** + * Do we add to our cache or not? + */ + noCache: boolean; } /** @@ -114,4 +118,5 @@ export const DEFAULT_INDEX_PRO_CODE_OPTIONS: IIndexProCodeOptions = { ...copy(DEFAULT_PARSER_OPTIONS), postProcess: true, changeDetection: true, + noCache: false, }; diff --git a/libs/parsing/index/src/lib/idl-parsed-cache.class.ts b/libs/parsing/index/src/lib/idl-parsed-cache.class.ts index 6a9fb3fa0..8ecdd40f0 100644 --- a/libs/parsing/index/src/lib/idl-parsed-cache.class.ts +++ b/libs/parsing/index/src/lib/idl-parsed-cache.class.ts @@ -207,4 +207,13 @@ export class IDLParsedCache { this.byFile[file].postProcessProblems = parsed.postProcessProblems; } } + + /** + * Updates semantic tokens + */ + updateSemantic(file: string, parsed: IParsed) { + if (file in this.byFile) { + this.byFile[file].semantic = parsed.semantic; + } + } } diff --git a/libs/parsing/index/src/lib/post-process/post-process-parsed.ts b/libs/parsing/index/src/lib/post-process/post-process-parsed.ts index 5340e0ce7..db8e8399d 100644 --- a/libs/parsing/index/src/lib/post-process/post-process-parsed.ts +++ b/libs/parsing/index/src/lib/post-process/post-process-parsed.ts @@ -49,6 +49,7 @@ export function PostProcessParsed( // update problems for our file index.trackSyntaxProblemsForFile(file, GetSyntaxProblems(parsed)); - // update problems + // update cache index.tokensByFile.updateProblems(file, parsed); + index.tokensByFile.updateSemantic(file, parsed); } diff --git a/libs/shared/src/lib/version.interface.ts b/libs/shared/src/lib/version.interface.ts index 8395b7c27..cb69be96c 100644 --- a/libs/shared/src/lib/version.interface.ts +++ b/libs/shared/src/lib/version.interface.ts @@ -1,4 +1,4 @@ /** * Version of the extension */ -export const VERSION = '4.2.1'; +export const VERSION = '4.2.2'; diff --git a/libs/vscode/notebooks/src/lib/conversion/create-output-text.ts b/libs/vscode/notebooks/src/lib/conversion/create-output-text.ts new file mode 100644 index 000000000..bf119399c --- /dev/null +++ b/libs/vscode/notebooks/src/lib/conversion/create-output-text.ts @@ -0,0 +1,34 @@ +import { EscapeHtml } from './escape'; + +/** + * Makes the HTML for nicely formatted text in our cell outputs + */ +export function CreateOutputText( + idx: number, + content: string, + style: 'text' | 'image' +) { + if (style === 'text') { + const string = ` + + + + +
[${idx}]:
${EscapeHtml(
+      content
+    )}
+ `; + + return string; + } else { + const string = ` + + + + +
[${idx}]:
+ `; + + return string; + } +} diff --git a/libs/vscode/notebooks/src/lib/conversion/escape.ts b/libs/vscode/notebooks/src/lib/conversion/escape.ts new file mode 100644 index 000000000..794eac692 --- /dev/null +++ b/libs/vscode/notebooks/src/lib/conversion/escape.ts @@ -0,0 +1,58 @@ +/* ! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */ + +const matchHtmlRegExp = /["'&<>]/; + +/** + * Escape special characters in the given string of text. + * + */ +export function EscapeHtml(string: string) { + const str = '' + string; + const match = matchHtmlRegExp.exec(str); + + if (!match) { + return str; + } + + let escape; + let html = ''; + let index = 0; + let lastIndex = 0; + + for (index = match.index; index < str.length; index++) { + switch (str.charCodeAt(index)) { + case 34: // " + escape = '"'; + break; + case 38: // & + escape = '&'; + break; + case 39: // ' + escape = '''; + break; + case 60: // < + escape = '<'; + break; + case 62: // > + escape = '>'; + break; + default: + continue; + } + + if (lastIndex !== index) { + html += str.substring(lastIndex, index); + } + + lastIndex = index + 1; + html += escape; + } + + return lastIndex !== index ? html + str.substring(lastIndex, index) : html; +} diff --git a/libs/vscode/notebooks/src/lib/conversion/notebook-to-markdown.ts b/libs/vscode/notebooks/src/lib/conversion/notebook-to-markdown.ts index bbd8cd520..587af0565 100644 --- a/libs/vscode/notebooks/src/lib/conversion/notebook-to-markdown.ts +++ b/libs/vscode/notebooks/src/lib/conversion/notebook-to-markdown.ts @@ -8,6 +8,8 @@ import { } from '@idl/notebooks/types'; import { NotebookCellKind, NotebookDocument } from 'vscode'; +import { CreateOutputText } from './create-output-text'; + /** * Converts a notebook to a markdown file */ @@ -61,6 +63,9 @@ export async function NotebookToMarkdown( // check for outputs const outputs = cell.outputs; + /** Track actual number of outputs */ + let nOut = 1; + // process each output for (let j = 0; j < outputs.length; j++) { // get output items @@ -89,12 +94,21 @@ export async function NotebookToMarkdown( */ switch (embedded.type) { case 'idlnotebookimage_png': + // markdown.push( + // `![](data:image/png;base64,${ + // ( + // embedded as IDLNotebookEmbeddedItem + // ).item.data + // })` + // ); markdown.push( - `![](data:image/png;base64,${ + CreateOutputText( + nOut, ( embedded as IDLNotebookEmbeddedItem - ).item.data - })` + ).item.data, + 'image' + ) ); // markdown.push(`![](./${nImages}.png)`); // writeFileSync( @@ -102,8 +116,9 @@ export async function NotebookToMarkdown( // (embedded as IDLNotebookEmbeddedItem) // .item.data // ); - nImages++; markdown.push(''); + nOut++; + nImages++; break; case 'idlnotebookmap': { const map = @@ -123,12 +138,16 @@ export async function NotebookToMarkdown( // `C:\\Users\\znorman\\.idl\\vscode\\notebooks\\examples\\${nImages}.png`, // firstImage.item.data // ); - nImages++; + // markdown.push( + // `![](data:image/png;base64,${firstImage.item.data})` + // ); markdown.push( - `![](data:image/png;base64,${firstImage.item.data})` + CreateOutputText(nOut, firstImage.item.data, 'image') ); markdown.push(''); + nOut++; + nImages++; } break; } @@ -136,10 +155,18 @@ export async function NotebookToMarkdown( break; } } else { - markdown.push('```'); - markdown = markdown.concat(asString.split(/\r?\n/g)); - markdown.push('```'); + markdown.push( + CreateOutputText( + nOut, + asString.split(/\r?\n/g).join('\n'), + 'text' + ) + ); + // markdown.push('```'); + // markdown = markdown.concat(asString.split(/\r?\n/g)); + // markdown.push('```'); markdown.push(''); + nOut++; } } } diff --git a/libs/vscode/server/src/lib/events/notebooks/send-notebook-problems.ts b/libs/vscode/server/src/lib/events/notebooks/send-notebook-problems.ts index 0bdb4ea9f..42c23050b 100644 --- a/libs/vscode/server/src/lib/events/notebooks/send-notebook-problems.ts +++ b/libs/vscode/server/src/lib/events/notebooks/send-notebook-problems.ts @@ -6,7 +6,5 @@ import { SendProblems } from '../../helpers/send-problems'; * Sends problems that have been detected in notebook cells */ export function SendNotebookProblems(notebook: NotebookDocument) { - SendProblems( - [notebook.uri].concat(notebook.cells.map((cell) => cell.document)) - ); + SendProblems(notebook.cells.map((cell) => cell.document)); } diff --git a/libs/vscode/server/src/lib/helpers/send-problems.ts b/libs/vscode/server/src/lib/helpers/send-problems.ts index da033aa07..84628ef75 100644 --- a/libs/vscode/server/src/lib/helpers/send-problems.ts +++ b/libs/vscode/server/src/lib/helpers/send-problems.ts @@ -106,12 +106,12 @@ export function SendProblems(inFiles: string[]) { * * We use parseProblems to store "undefined" as a flag to sync files so we need an extra check */ - if (files[i] in parseProblems) { - problems = parseProblems[files[i]]; + if (parseProblems[files[i]]) { + problems = problems.concat(parseProblems[files[i]]); } // check for global problems - if (files[i] in globalProblems) { + if (globalProblems[files[i]]) { problems = problems.concat(globalProblems[files[i]]); } diff --git a/package-lock.json b/package-lock.json index cedb63494..6453aac42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "idl-for-vscode", - "version": "4.2.1", + "version": "4.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "idl-for-vscode", - "version": "4.2.1", + "version": "4.2.2", "license": "MIT", "dependencies": { "@vscode/debugadapter": "^1.64.0", diff --git a/package.json b/package.json index 05854c4c8..49dc143da 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "idl-for-vscode", "displayName": "%packageJSON.displayName%", "description": "%packageJSON.description%", - "version": "4.2.1", + "version": "4.2.2", "publisher": "idl", "license": "MIT", "encryption": "yes",