Skip to content

Commit

Permalink
Apply more settings for final newlines and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Oct 29, 2024
1 parent 2896aec commit 67bbd89
Show file tree
Hide file tree
Showing 33 changed files with 41 additions and 60 deletions.
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
"editor.formatOnSave": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"editor.tabSize": 2
}
"editor.tabSize": 2,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true
}
2 changes: 1 addition & 1 deletion apps/vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
out/
*.vsix
*.vsix
1 change: 0 additions & 1 deletion apps/vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ src/**
**/*.map
**/*.ts
*.vsix

2 changes: 1 addition & 1 deletion apps/vscode/.yarnrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--ignore-engines true
--ignore-engines true
6 changes: 2 additions & 4 deletions apps/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 <kbd>Ctrl+Shift+K</kbd> 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 <kbd>Ctrl+Shift+K</kbd> 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.
Expand All @@ -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
```
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/assets/www/editor/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
index.js
style.css
style.css
2 changes: 1 addition & 1 deletion apps/vscode/languages/dot/dot.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
")"
]
]
}
}
2 changes: 1 addition & 1 deletion apps/vscode/languages/mermaid/mermaid.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
")"
]
]
}
}
2 changes: 1 addition & 1 deletion apps/vscode/languages/mermaid/mermaid.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -883,4 +883,4 @@
}
},
"scopeName": "source.mmd"
}
}
2 changes: 1 addition & 1 deletion apps/vscode/languages/typst/typst.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
")"
]
]
}
}
3 changes: 0 additions & 3 deletions apps/vscode/src/@types/hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,3 @@ declare module 'positron' {
readonly previewPanel: PreviewPanel;
}
}



4 changes: 2 additions & 2 deletions apps/vscode/src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export async function safeUpdateConfig(updateFn: () => Promise<void>) {
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)");
}
}
}
1 change: 0 additions & 1 deletion apps/vscode/src/core/hover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ export async function getSignatureHelpHover(
triggerCharacter
);
}

1 change: 0 additions & 1 deletion apps/vscode/src/core/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ export function pythonIsCondaEnv(python: string) {
return false;
}
}

1 change: 0 additions & 1 deletion apps/vscode/src/core/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,3 @@ function requiredTerminalDelay(env?: TerminalEnv): number {
return 0;
}
}

2 changes: 1 addition & 1 deletion apps/vscode/src/core/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export function activeWorkspaceFolder(uri?: Uri): WorkspaceFolder | undefined {
? workspace.workspaceFolders[0]
: undefined;
return workspaceFolder;
}
}
2 changes: 1 addition & 1 deletion apps/vscode/src/host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ function defaultExtensionHost(): ExtensionHost {
},
createPreviewPanel,
};
}
}
2 changes: 0 additions & 2 deletions apps/vscode/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,3 @@ function isWithinYamlComment(doc: TextDocument, pos: Position) {
const line = doc.lineAt(pos.line).text;
return !!line.match(/^\s*#\s*\| /);
}


3 changes: 1 addition & 2 deletions apps/vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -130,4 +130,3 @@ export async function activate(context: vscode.ExtensionContext) {
export async function deactivate() {
return deactivateLsp();
}

2 changes: 1 addition & 1 deletion apps/vscode/src/providers/assist/render-assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function renderWebviewHtml(webview: Webview, extensionUri: Uri) {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="${styleUri}" rel="stylesheet">
<title>Quarto Lens</title>
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion apps/vscode/src/providers/create/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ export async function activateCreate(
),
];
}

6 changes: 0 additions & 6 deletions apps/vscode/src/providers/deno-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,3 @@ export function activateDenoConfig(context: ExtensionContext, engine: MarkdownEn
workspace.onDidSaveTextDocument(ensureDenoConfig, null, context.subscriptions);
}
}






4 changes: 2 additions & 2 deletions apps/vscode/src/providers/editor/codeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -285,4 +285,4 @@ function mdStringToMdContent(mdString: MarkdownString): MarkupContent {
kind: MarkupKind.Markdown,
value: mdString.value
};
}
}
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/editor/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ function webviewPanelPostMessageTarget(webviewPanel: WebviewPanel): JsonRpcPostM
};
}
};
}
}
10 changes: 5 additions & 5 deletions apps/vscode/src/providers/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion apps/vscode/src/providers/editor/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,3 @@ export function documentImageResolver(
}
};
}

1 change: 0 additions & 1 deletion apps/vscode/src/providers/editor/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,3 @@ function writePerDocumentPrefs(document: TextDocument, prefs: PerDocumentPrefs)
const storage = filePrefsStorage(document.uri.fsPath);
writeFileSync(storage, JSON.stringify(prefs), { encoding: "utf8" });
}

13 changes: 6 additions & 7 deletions apps/vscode/src/providers/editor/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ 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:
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:
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -208,4 +208,3 @@ async function updateWorkspaceDocument(document: TextDocument, markdown: string)
updateDocument(editor, document, markdown);
await workspace.applyEdit(edit);
};

2 changes: 1 addition & 1 deletion apps/vscode/src/providers/editor/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/vscode/src/providers/preview/preview-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions apps/vscode/src/providers/zotero/zotero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -366,4 +366,4 @@ async function safeReadZoteroApiKey(context: ExtensionContext) {
console.log("Error reading zotero api key");
return undefined;
}
}
}
2 changes: 1 addition & 1 deletion apps/vscode/src/vdoc/vdoc-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export async function vdocCompletions(
return completion;
});

}
}
4 changes: 2 additions & 2 deletions apps/vscode/src/vdoc/vdoc-tempfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export async function virtualDocUriFromTempFile(
local: boolean
): Promise<VirtualDocUri> {

// 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}`);
Expand Down

0 comments on commit 67bbd89

Please sign in to comment.