Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live share integration #4308

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 86 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 20 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@
}
],
"commands": [
{
"command": "latex-workshop.acquireHostPort",
"title": "Acquire Live Share host port",
"category": "LaTeX Workshop"
},
{
"command": "latex-workshop.shareHostPort",
"title": "Share Live Share host port",
"category": "LaTeX Workshop"
},
James-Yu marked this conversation as resolved.
Show resolved Hide resolved
{
"command": "latex-workshop.navigate-envpair",
"title": "%command.navigate-envpair%",
Expand Down Expand Up @@ -357,8 +367,7 @@
"command": "latex-workshop.view",
"title": "%command.view%",
"category": "LaTeX Workshop",
"icon": "$(open-preview)",
"enablement": "!virtualWorkspace"
"icon": "$(open-preview)"
},
{
"command": "latex-workshop.tab",
Expand All @@ -368,8 +377,7 @@
{
"command": "latex-workshop.viewInBrowser",
"title": "%command.viewInBrowser%",
"category": "LaTeX Workshop",
"enablement": "!virtualWorkspace"
"category": "LaTeX Workshop"
},
{
"command": "latex-workshop.viewExternal",
Expand All @@ -391,8 +399,7 @@
{
"command": "latex-workshop.synctex",
"title": "%command.synctex%",
"category": "LaTeX Workshop",
"enablement": "!virtualWorkspace"
"category": "LaTeX Workshop"
},
{
"command": "latex-workshop.clean",
Expand All @@ -403,8 +410,7 @@
{
"command": "latex-workshop.citation",
"title": "%command.citation%",
"category": "LaTeX Workshop",
"enablement": "!virtualWorkspace"
"category": "LaTeX Workshop"
},
{
"command": "latex-workshop.addtexroot",
Expand Down Expand Up @@ -541,13 +547,13 @@
"key": "ctrl+l alt+v",
"mac": "cmd+l alt+v",
"command": "latex-workshop.view",
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/ && config.latex-workshop.bind.altKeymap.enabled && !virtualWorkspace"
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/ && config.latex-workshop.bind.altKeymap.enabled"
},
{
"key": "ctrl+l alt+j",
"mac": "cmd+l alt+j",
"command": "latex-workshop.synctex",
"when": "editorTextFocus && editorLangId =~ /^latex$|^latex-expl3$|^doctex$/ && config.latex-workshop.bind.altKeymap.enabled && !virtualWorkspace"
"when": "editorTextFocus && editorLangId =~ /^latex$|^latex-expl3$|^doctex$/ && config.latex-workshop.bind.altKeymap.enabled"
},
{
"key": "ctrl+l alt+x",
Expand Down Expand Up @@ -577,13 +583,13 @@
"key": "ctrl+alt+v",
"mac": "cmd+alt+v",
"command": "latex-workshop.view",
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/ && !config.latex-workshop.bind.altKeymap.enabled && !virtualWorkspace"
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/ && !config.latex-workshop.bind.altKeymap.enabled"
},
{
"key": "ctrl+alt+j",
"mac": "cmd+alt+j",
"command": "latex-workshop.synctex",
"when": "editorTextFocus && editorLangId =~ /^latex$|^latex-expl3$|^doctex$/ && !config.latex-workshop.bind.altKeymap.enabled && !virtualWorkspace"
"when": "editorTextFocus && editorLangId =~ /^latex$|^latex-expl3$|^doctex$/ && !config.latex-workshop.bind.altKeymap.enabled"
},
{
"key": "ctrl+alt+x",
Expand Down Expand Up @@ -2493,7 +2499,7 @@
],
"editor/title": [
{
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/ && !virtualWorkspace",
"when": "editorLangId =~ /^latex$|^latex-expl3$|^doctex$|^rsweave$|^jlweave$|^pweave$/",
"command": "latex-workshop.view",
"group": "navigation@2"
},
Expand Down Expand Up @@ -2570,6 +2576,7 @@
"micromatch": "4.0.5",
"pdfjs-dist": "4.3.136",
"tmp": "0.2.3",
"vsls": "1.0.4753",
"workerpool": "9.1.1",
"ws": "8.17.1"
},
Expand Down
12 changes: 6 additions & 6 deletions src/compile/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ lw.watcher.bib.onChange(filePath => autoBuild(filePath, 'onFileChange', true))
* changed.
*/
function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: boolean = false) {
const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(file))
const configuration = vscode.workspace.getConfiguration('latex-workshop', lw.file.getUri(file))
if (configuration.get('latex.autoBuild.run') as string !== type) {
return
}
Expand All @@ -57,7 +57,7 @@ function autoBuild(file: string, type: 'onFileChange' | 'onSave', bibChanged: bo
* @returns {boolean} - True if auto-build can be triggered, false otherwise.
*/
function canAutoBuild(): boolean {
const configuration = vscode.workspace.getConfiguration('latex-workshop', lw.root.file.path ? vscode.Uri.file(lw.root.file.path) : undefined)
const configuration = vscode.workspace.getConfiguration('latex-workshop', lw.root.file.path ? lw.file.getUri(lw.root.file.path) : undefined)
return Date.now() - lw.compile.lastAutoBuildTime >= (configuration.get('latex.autoBuild.interval', 1000) as number)
}

Expand Down Expand Up @@ -91,7 +91,7 @@ async function build(skipSelection: boolean = false, rootFile: string | undefine

logger.log(`The document of the active editor: ${activeEditor.document.uri.toString(true)}`)
logger.log(`The languageId of the document: ${activeEditor.document.languageId}`)
const workspace = rootFile ? vscode.Uri.file(rootFile) : activeEditor.document.uri
const workspace = rootFile ? lw.file.getUri(rootFile) : activeEditor.document.uri
const configuration = vscode.workspace.getConfiguration('latex-workshop', workspace)
const externalBuildCommand = configuration.get('latex.external.build.command') as string
const externalBuildArgs = configuration.get('latex.external.build.args') as string[]
Expand Down Expand Up @@ -187,7 +187,7 @@ async function buildLoop() {
* process.
*/
function spawnProcess(step: Step): ProcessEnv {
const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? vscode.Uri.file(step.rootFile) : undefined)
const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? lw.file.getUri(step.rootFile) : undefined)
if (step.index === 0 || configuration.get('latex.build.clearLog.everyRecipeStep.enabled') as boolean) {
logger.clearCompilerMessage()
}
Expand Down Expand Up @@ -332,7 +332,7 @@ function handleExitCodeError(step: Step, env: ProcessEnv, stderr: string, code:
logger.log(`${stderr}`)
}

const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? vscode.Uri.file(step.rootFile) : undefined)
const configuration = vscode.workspace.getConfiguration('latex-workshop', step.rootFile ? lw.file.getUri(step.rootFile) : undefined)
if (!step.isExternal && signal !== 'SIGTERM' && !step.isRetry && configuration.get('latex.autoBuild.cleanAndRetry.enabled')) {
handleRetryError(step)
} else if (!step.isExternal && signal !== 'SIGTERM') {
Expand Down Expand Up @@ -423,7 +423,7 @@ async function afterSuccessfulBuilt(lastStep: Step, skipped: boolean) {
lw.viewer.refresh(lw.file.getPdfPath(lastStep.rootFile))
lw.completion.reference.setNumbersFromAuxFile(lastStep.rootFile)
await lw.cache.loadFlsFile(lastStep.rootFile ?? '')
const configuration = vscode.workspace.getConfiguration('latex-workshop', vscode.Uri.file(lastStep.rootFile))
const configuration = vscode.workspace.getConfiguration('latex-workshop', lw.file.getUri(lastStep.rootFile))
// If the PDF viewer is internal, we call SyncTeX in src/components/viewer.ts.
if (configuration.get('view.pdf.viewer') === 'external' && configuration.get('synctex.afterBuild.enabled')) {
const pdfFile = lw.file.getPdfPath(lastStep.rootFile)
Expand Down
3 changes: 2 additions & 1 deletion src/compile/queue.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import vscode from 'vscode'
import type { ExternalStep, RecipeStep, Step, StepQueue, Tool } from '../types'
import { lw } from '../lw'

const stepQueue: StepQueue = { steps: [], nextSteps: [] }

Expand Down Expand Up @@ -99,7 +100,7 @@ function getStepString(step: Step): string {

// Determine the format of the stepString based on timestamp and index
if(step.rootFile) {
const rootFileUri = vscode.Uri.file(step.rootFile)
const rootFileUri = lw.file.getUri(step.rootFile)
const configuration = vscode.workspace.getConfiguration('latex-workshop', rootFileUri)
const showFilename = configuration.get<boolean>('latex.build.rootfileInStatus', false)
if(showFilename) {
Expand Down
Loading
Loading