From 67bbd89d48d85cb3770f0fc95938cd8e703fcfdd Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 29 Oct 2024 14:24:20 -0600 Subject: [PATCH] Apply more settings for final newlines and whitespace --- .vscode/settings.json | 7 +++++-- apps/vscode/.gitignore | 2 +- apps/vscode/.vscodeignore | 1 - apps/vscode/.yarnrc | 2 +- apps/vscode/README.md | 6 ++---- apps/vscode/assets/www/editor/.gitignore | 2 +- apps/vscode/languages/dot/dot.configuration.json | 2 +- .../languages/mermaid/mermaid.configuration.json | 2 +- .../languages/mermaid/mermaid.tmLanguage.json | 2 +- .../vscode/languages/typst/typst.configuration.json | 2 +- apps/vscode/src/@types/hooks.d.ts | 3 --- apps/vscode/src/core/config.ts | 4 ++-- apps/vscode/src/core/hover.ts | 1 - apps/vscode/src/core/python.ts | 1 - apps/vscode/src/core/terminal.ts | 1 - apps/vscode/src/core/workspace.ts | 2 +- apps/vscode/src/host/index.ts | 2 +- apps/vscode/src/lsp/client.ts | 2 -- apps/vscode/src/main.ts | 3 +-- apps/vscode/src/providers/assist/render-assist.ts | 2 +- apps/vscode/src/providers/create/create.ts | 1 - apps/vscode/src/providers/deno-config.ts | 6 ------ apps/vscode/src/providers/editor/codeview.ts | 4 ++-- apps/vscode/src/providers/editor/connection.ts | 2 +- apps/vscode/src/providers/editor/editor.ts | 10 +++++----- apps/vscode/src/providers/editor/images.ts | 1 - apps/vscode/src/providers/editor/prefs.ts | 1 - apps/vscode/src/providers/editor/sync.ts | 13 ++++++------- apps/vscode/src/providers/editor/toggle.ts | 2 +- apps/vscode/src/providers/preview/preview-env.ts | 2 +- apps/vscode/src/providers/zotero/zotero.ts | 4 ++-- apps/vscode/src/vdoc/vdoc-completion.ts | 2 +- apps/vscode/src/vdoc/vdoc-tempfile.ts | 4 ++-- 33 files changed, 41 insertions(+), 60 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 15988045..f5aa9faf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,8 @@ "editor.formatOnSave": true }, "typescript.tsdk": "node_modules/typescript/lib", - "editor.tabSize": 2 -} \ No newline at end of file + "editor.tabSize": 2, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.trimTrailingWhitespace": true +} diff --git a/apps/vscode/.gitignore b/apps/vscode/.gitignore index d3ba603c..808e1d34 100644 --- a/apps/vscode/.gitignore +++ b/apps/vscode/.gitignore @@ -1,2 +1,2 @@ out/ -*.vsix \ No newline at end of file +*.vsix diff --git a/apps/vscode/.vscodeignore b/apps/vscode/.vscodeignore index 8c3e80d2..62b702c8 100644 --- a/apps/vscode/.vscodeignore +++ b/apps/vscode/.vscodeignore @@ -10,4 +10,3 @@ src/** **/*.map **/*.ts *.vsix - diff --git a/apps/vscode/.yarnrc b/apps/vscode/.yarnrc index f757a6ac..4f14322d 100644 --- a/apps/vscode/.yarnrc +++ b/apps/vscode/.yarnrc @@ -1 +1 @@ ---ignore-engines true \ No newline at end of file +--ignore-engines true diff --git a/apps/vscode/README.md b/apps/vscode/README.md index b507ad6d..89bdec6d 100644 --- a/apps/vscode/README.md +++ b/apps/vscode/README.md @@ -21,7 +21,6 @@ The easiest way to install is directly from within VS Code (search extensions fo You can also install from the [VS Code Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=quarto.quarto), the [Open VSX Registry](https://open-vsx.org/extension/quarto/quarto) or directly from a [VISX extension file](#visx-install). - ## Render and Preview The Quarto VS Code extension includes commands and keyboard shortcuts for rendering Quarto documents (both standalone and within websites or books). After rendering, `quarto preview` is used behind the scenes to provide a preview pane within VS Code alongside your document: @@ -44,7 +43,7 @@ When you execute **Preview Format**, you'll see a quick pick list of formats to ![](https://quarto.org/docs/tools/images/vscode-preview-format.png) -After previewing a different format, the **Quarto: Preview** command and Ctrl+Shift+K keyboard shortcut will be automatically rebound to the newly selected format for the duration of the current preview. To switch back to previewing the original format, use **Quarto: Preview Format** command again. +After previewing a different format, the **Quarto: Preview** command and Ctrl+Shift+K keyboard shortcut will be automatically rebound to the newly selected format for the duration of the current preview. To switch back to previewing the original format, use **Quarto: Preview Format** command again. > Embedded preview is currently supported for HTML and PDF based formats (including `revealjs` and `beamer` slideshows). However, for Word and other formats you need to use an appropriate external program to preview the output. @@ -64,7 +63,7 @@ However, you can configure the Quarto extension to automatically render whenever You might also want to control this behavior on a per-document or per-project basis. If you include the `editor: render-on-save` option in your document or project YAML it will supersede whatever your VS Code setting is. For example: -``` yaml +```yaml editor: render-on-save: true ``` @@ -75,7 +74,6 @@ If you prefer to use an external browser for preview (or have no preview trigger ![](https://quarto.org/docs/tools/images/vscode-preview-settings.png) - ## Code Cells There are a variety of tools that make it easier to edit and execute diff --git a/apps/vscode/assets/www/editor/.gitignore b/apps/vscode/assets/www/editor/.gitignore index d51579d1..a4e42b6d 100644 --- a/apps/vscode/assets/www/editor/.gitignore +++ b/apps/vscode/assets/www/editor/.gitignore @@ -1,2 +1,2 @@ index.js -style.css \ No newline at end of file +style.css diff --git a/apps/vscode/languages/dot/dot.configuration.json b/apps/vscode/languages/dot/dot.configuration.json index 4051e9f2..305f6347 100644 --- a/apps/vscode/languages/dot/dot.configuration.json +++ b/apps/vscode/languages/dot/dot.configuration.json @@ -20,4 +20,4 @@ ")" ] ] -} \ No newline at end of file +} diff --git a/apps/vscode/languages/mermaid/mermaid.configuration.json b/apps/vscode/languages/mermaid/mermaid.configuration.json index 086c6e3b..dfd0fab0 100644 --- a/apps/vscode/languages/mermaid/mermaid.configuration.json +++ b/apps/vscode/languages/mermaid/mermaid.configuration.json @@ -16,4 +16,4 @@ ")" ] ] -} \ No newline at end of file +} diff --git a/apps/vscode/languages/mermaid/mermaid.tmLanguage.json b/apps/vscode/languages/mermaid/mermaid.tmLanguage.json index 958b1d58..717f9721 100644 --- a/apps/vscode/languages/mermaid/mermaid.tmLanguage.json +++ b/apps/vscode/languages/mermaid/mermaid.tmLanguage.json @@ -883,4 +883,4 @@ } }, "scopeName": "source.mmd" -} \ No newline at end of file +} diff --git a/apps/vscode/languages/typst/typst.configuration.json b/apps/vscode/languages/typst/typst.configuration.json index 4051e9f2..305f6347 100644 --- a/apps/vscode/languages/typst/typst.configuration.json +++ b/apps/vscode/languages/typst/typst.configuration.json @@ -20,4 +20,4 @@ ")" ] ] -} \ No newline at end of file +} diff --git a/apps/vscode/src/@types/hooks.d.ts b/apps/vscode/src/@types/hooks.d.ts index 99ae993e..66abfa90 100644 --- a/apps/vscode/src/@types/hooks.d.ts +++ b/apps/vscode/src/@types/hooks.d.ts @@ -72,6 +72,3 @@ declare module 'positron' { readonly previewPanel: PreviewPanel; } } - - - diff --git a/apps/vscode/src/core/config.ts b/apps/vscode/src/core/config.ts index bf89a409..ad782fff 100644 --- a/apps/vscode/src/core/config.ts +++ b/apps/vscode/src/core/config.ts @@ -19,8 +19,8 @@ export async function safeUpdateConfig(updateFn: () => Promise) { try { await updateFn(); } catch (error) { - // if the user's settings.json file is corrupt/invalid this + // if the user's settings.json file is corrupt/invalid this // will throw an exception and prevent loading of the extension console.log("Unexpected error writing config (settings.json may be corrupt)"); } -} \ No newline at end of file +} diff --git a/apps/vscode/src/core/hover.ts b/apps/vscode/src/core/hover.ts index a05608b3..b0825488 100644 --- a/apps/vscode/src/core/hover.ts +++ b/apps/vscode/src/core/hover.ts @@ -57,4 +57,3 @@ export async function getSignatureHelpHover( triggerCharacter ); } - diff --git a/apps/vscode/src/core/python.ts b/apps/vscode/src/core/python.ts index 489e374e..56c2bd85 100644 --- a/apps/vscode/src/core/python.ts +++ b/apps/vscode/src/core/python.ts @@ -71,4 +71,3 @@ export function pythonIsCondaEnv(python: string) { return false; } } - diff --git a/apps/vscode/src/core/terminal.ts b/apps/vscode/src/core/terminal.ts index 997d2887..40410b29 100644 --- a/apps/vscode/src/core/terminal.ts +++ b/apps/vscode/src/core/terminal.ts @@ -184,4 +184,3 @@ function requiredTerminalDelay(env?: TerminalEnv): number { return 0; } } - diff --git a/apps/vscode/src/core/workspace.ts b/apps/vscode/src/core/workspace.ts index dc8ad8fd..0ca69b93 100644 --- a/apps/vscode/src/core/workspace.ts +++ b/apps/vscode/src/core/workspace.ts @@ -22,4 +22,4 @@ export function activeWorkspaceFolder(uri?: Uri): WorkspaceFolder | undefined { ? workspace.workspaceFolders[0] : undefined; return workspaceFolder; -} \ No newline at end of file +} diff --git a/apps/vscode/src/host/index.ts b/apps/vscode/src/host/index.ts index 0f8295de..bfbd8bf5 100644 --- a/apps/vscode/src/host/index.ts +++ b/apps/vscode/src/host/index.ts @@ -105,4 +105,4 @@ function defaultExtensionHost(): ExtensionHost { }, createPreviewPanel, }; -} \ No newline at end of file +} diff --git a/apps/vscode/src/lsp/client.ts b/apps/vscode/src/lsp/client.ts index c527b2d1..c54753eb 100644 --- a/apps/vscode/src/lsp/client.ts +++ b/apps/vscode/src/lsp/client.ts @@ -349,5 +349,3 @@ function isWithinYamlComment(doc: TextDocument, pos: Position) { const line = doc.lineAt(pos.line).text; return !!line.match(/^\s*#\s*\| /); } - - diff --git a/apps/vscode/src/main.ts b/apps/vscode/src/main.ts index 4371c4e5..dfedbba4 100644 --- a/apps/vscode/src/main.ts +++ b/apps/vscode/src/main.ts @@ -90,7 +90,7 @@ export async function activate(context: vscode.ExtensionContext) { const editorCommands = activateEditor(context, host, quartoContext, lspClient, engine); commands.push(...editorCommands); - // zotero + // zotero const zoteroCommands = await activateZotero(context, lspClient); commands.push(...zoteroCommands); @@ -130,4 +130,3 @@ export async function activate(context: vscode.ExtensionContext) { export async function deactivate() { return deactivateLsp(); } - diff --git a/apps/vscode/src/providers/assist/render-assist.ts b/apps/vscode/src/providers/assist/render-assist.ts index 21b918ec..a067d969 100644 --- a/apps/vscode/src/providers/assist/render-assist.ts +++ b/apps/vscode/src/providers/assist/render-assist.ts @@ -64,7 +64,7 @@ export function renderWebviewHtml(webview: Webview, extensionUri: Uri) { - + Quarto Lens diff --git a/apps/vscode/src/providers/create/create.ts b/apps/vscode/src/providers/create/create.ts index 1de82605..8e2a1291 100644 --- a/apps/vscode/src/providers/create/create.ts +++ b/apps/vscode/src/providers/create/create.ts @@ -41,4 +41,3 @@ export async function activateCreate( ), ]; } - diff --git a/apps/vscode/src/providers/deno-config.ts b/apps/vscode/src/providers/deno-config.ts index 4188ff20..2fa972df 100644 --- a/apps/vscode/src/providers/deno-config.ts +++ b/apps/vscode/src/providers/deno-config.ts @@ -43,9 +43,3 @@ export function activateDenoConfig(context: ExtensionContext, engine: MarkdownEn workspace.onDidSaveTextDocument(ensureDenoConfig, null, context.subscriptions); } } - - - - - - diff --git a/apps/vscode/src/providers/editor/codeview.ts b/apps/vscode/src/providers/editor/codeview.ts index 1d08938c..c352e3b7 100644 --- a/apps/vscode/src/providers/editor/codeview.ts +++ b/apps/vscode/src/providers/editor/codeview.ts @@ -133,7 +133,7 @@ function lspCellYamlOptionsCompletions(context: CodeViewCompletionContext, lspRe }); // include language header (we offset cellEnd below accordingly) code.splice(context.cellBegin, 0, `{${context.language}}`); - // make request + // make request return lspRequest(kCodeViewGetCompletions, [{ ...context, code, @@ -285,4 +285,4 @@ function mdStringToMdContent(mdString: MarkdownString): MarkupContent { kind: MarkupKind.Markdown, value: mdString.value }; -} \ No newline at end of file +} diff --git a/apps/vscode/src/providers/editor/connection.ts b/apps/vscode/src/providers/editor/connection.ts index e5783280..7fc90685 100644 --- a/apps/vscode/src/providers/editor/connection.ts +++ b/apps/vscode/src/providers/editor/connection.ts @@ -176,4 +176,4 @@ function webviewPanelPostMessageTarget(webviewPanel: WebviewPanel): JsonRpcPostM }; } }; -} \ No newline at end of file +} diff --git a/apps/vscode/src/providers/editor/editor.ts b/apps/vscode/src/providers/editor/editor.ts index 52afddfa..7514cbe6 100644 --- a/apps/vscode/src/providers/editor/editor.ts +++ b/apps/vscode/src/providers/editor/editor.ts @@ -116,12 +116,12 @@ export class VisualEditorProvider implements CustomTextEditorProvider { engine: MarkdownEngine ): Disposable { - // setup request transport + // setup request transport const lspRequest = lspClientTransport(lspClient); // track edits in the active editor if its untitled. this enables us to recover the // content when we switch to an untitled document, which otherwise are just dropped - // on the floor by vscode + // on the floor by vscode context.subscriptions.push(workspace.onDidChangeTextDocument(e => { const doc = window.activeTextEditor?.document; if (doc && isQuartoDoc(doc) && doc.isUntitled && (doc.uri.toString() === e.document.uri.toString())) { @@ -326,7 +326,7 @@ export class VisualEditorProvider implements CustomTextEditorProvider { xref || sourcePos ); - // editor container implementation + // editor container implementation const host: VSCodeVisualEditorHost = { // editor is querying for context @@ -632,7 +632,7 @@ function visualEditorTracker(): VisualEditorTracker { try { return editor.webviewPanel.active || (includeVisible && editor.webviewPanel.visible); } catch (err) { - // we've seen activeEditors hold on to references to disposed editors (can't on the + // we've seen activeEditors hold on to references to disposed editors (can't on the // surface see how this would occur as we subscribe to dispose, but as an insurance // policy let's eat any exception that occurs, since a single zombie webviewPanel // would prevent rendering of other panels @@ -668,7 +668,7 @@ function focusTracker(webviewPanel: WebviewPanel, editor: VSCodeVisualEditor): D } }); - // periodically check for focus + // periodically check for focus const timer = setInterval(async () => { // update focus state hasFocus = await editor.isFocused(); diff --git a/apps/vscode/src/providers/editor/images.ts b/apps/vscode/src/providers/editor/images.ts index d92a2324..a2ecd467 100644 --- a/apps/vscode/src/providers/editor/images.ts +++ b/apps/vscode/src/providers/editor/images.ts @@ -129,4 +129,3 @@ export function documentImageResolver( } }; } - diff --git a/apps/vscode/src/providers/editor/prefs.ts b/apps/vscode/src/providers/editor/prefs.ts index 16cb6522..81345178 100644 --- a/apps/vscode/src/providers/editor/prefs.ts +++ b/apps/vscode/src/providers/editor/prefs.ts @@ -320,4 +320,3 @@ function writePerDocumentPrefs(document: TextDocument, prefs: PerDocumentPrefs) const storage = filePrefsStorage(document.uri.fsPath); writeFileSync(storage, JSON.stringify(prefs), { encoding: "utf8" }); } - diff --git a/apps/vscode/src/providers/editor/sync.ts b/apps/vscode/src/providers/editor/sync.ts index d2fbbb1c..f34fa2c7 100644 --- a/apps/vscode/src/providers/editor/sync.ts +++ b/apps/vscode/src/providers/editor/sync.ts @@ -21,11 +21,11 @@ import { isXRef, NavLocation, VSCodeVisualEditor, XRef } from "editor-types"; import { getWholeRange } from "../../core/doc"; -/* Strategy for managing synchronization of edits between source and visual mode. +/* Strategy for managing synchronization of edits between source and visual mode. -This is made more complicated by the fact that getting/setting visual editor markdown +This is made more complicated by the fact that getting/setting visual editor markdown is expensive (requires a pandoc round trip) so is throttled by 1 second. We also need -to guard against edits pinging back and forth (esp. w/ the requirement on flushing all +to guard against edits pinging back and forth (esp. w/ the requirement on flushing all pending edits on save) For the visual editor syncing to external changes: @@ -33,7 +33,7 @@ For the visual editor syncing to external changes: 1) Only accept external edits when NOT focused (once the visual editor is focused it is the definitive source of changes to the document) -2) These external edits are throttled by 1 second so we don't get constant (expensive) +2) These external edits are throttled by 1 second so we don't get constant (expensive) refreshing of the visual editor when users type in the text editor. For the visual editor propagating its own changes: @@ -65,9 +65,9 @@ export function editorSyncManager( navigation?: XRef | number ): EditorSyncManager { - // state: an update from the visual editor that we have yet to apply. we don't + // state: an update from the visual editor that we have yet to apply. we don't // apply these on every keystoke b/c they are expensive. we poll to apply these - // udpates periodically and also apply them immediately on save and when the + // udpates periodically and also apply them immediately on save and when the // visual editor instructs us to do so (e.g. when it loses focus) let pendingVisualEdit: unknown | undefined; @@ -208,4 +208,3 @@ async function updateWorkspaceDocument(document: TextDocument, markdown: string) updateDocument(editor, document, markdown); await workspace.applyEdit(edit); }; - diff --git a/apps/vscode/src/providers/editor/toggle.ts b/apps/vscode/src/providers/editor/toggle.ts index 95bb0545..b48a4213 100644 --- a/apps/vscode/src/providers/editor/toggle.ts +++ b/apps/vscode/src/providers/editor/toggle.ts @@ -76,7 +76,7 @@ export async function reopenEditorInSourceMode( // note pending switch to source VisualEditorProvider.recordPendingSwitchToSource(document); - // close editor (return immediately as if we don't then any + // close editor (return immediately as if we don't then any // rpc method that calls this wil result in an error b/c the webview // has been torn down by the time we return) commands.executeCommand('workbench.action.closeActiveEditor').then(async () => { diff --git a/apps/vscode/src/providers/preview/preview-env.ts b/apps/vscode/src/providers/preview/preview-env.ts index d56820c3..97815955 100644 --- a/apps/vscode/src/providers/preview/preview-env.ts +++ b/apps/vscode/src/providers/preview/preview-env.ts @@ -51,7 +51,7 @@ export class PreviewEnvManager { // eslint-disable-next-line @typescript-eslint/naming-convention QUARTO_LOG: this.outputFile_, - // eslint-disable-next-line @typescript-eslint/naming-convention + // eslint-disable-next-line @typescript-eslint/naming-convention QUARTO_RENDER_TOKEN: this.renderToken_, ...(await terminalEnv(uri)) diff --git a/apps/vscode/src/providers/zotero/zotero.ts b/apps/vscode/src/providers/zotero/zotero.ts index 32ad732e..1088ee30 100644 --- a/apps/vscode/src/providers/zotero/zotero.ts +++ b/apps/vscode/src/providers/zotero/zotero.ts @@ -222,7 +222,7 @@ class ZoteroConfigureLibraryCommand implements Command { inputBox.placeholder = "Zotero Web API Key"; inputBox.onDidAccept(async () => { - // get key + // get key const apiKey = inputBox.value.trim(); // helper to save it @@ -366,4 +366,4 @@ async function safeReadZoteroApiKey(context: ExtensionContext) { console.log("Error reading zotero api key"); return undefined; } -} \ No newline at end of file +} diff --git a/apps/vscode/src/vdoc/vdoc-completion.ts b/apps/vscode/src/vdoc/vdoc-completion.ts index 82c4cf49..84310c74 100644 --- a/apps/vscode/src/vdoc/vdoc-completion.ts +++ b/apps/vscode/src/vdoc/vdoc-completion.ts @@ -53,4 +53,4 @@ export async function vdocCompletions( return completion; }); -} \ No newline at end of file +} diff --git a/apps/vscode/src/vdoc/vdoc-tempfile.ts b/apps/vscode/src/vdoc/vdoc-tempfile.ts index 3dc11b28..8400a8c3 100644 --- a/apps/vscode/src/vdoc/vdoc-tempfile.ts +++ b/apps/vscode/src/vdoc/vdoc-tempfile.ts @@ -38,8 +38,8 @@ export async function virtualDocUriFromTempFile( local: boolean ): Promise { - // if this is local then create it alongside the docPath and return a cleanup - // function to remove it when the action is completed. + // if this is local then create it alongside the docPath and return a cleanup + // function to remove it when the action is completed. if (local || virtualDoc.language.localTempFile) { const ext = virtualDoc.language.extension; const vdocPath = path.join(path.dirname(docPath), `.vdoc.${ext}`);