Skip to content

Commit

Permalink
Make url and port viewer configurable
Browse files Browse the repository at this point in the history
    latex-workshop.viewer.pdf.internal.url
    latex-workshop.viewer.pdf.internal.port
  • Loading branch information
jlelong committed Apr 3, 2019
1 parent efadbb9 commit f2aed5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,16 @@
],
"markdownDescription": "PDF viewer used for [View on PDF] link on \\ref."
},
"latex-workshop.viewer.pdf.internal.url": {
"type": "string",
"default": "127.0.0.1",
"markdownDescription": "Define the url to listen to for communicating with the internal viewer."
},
"latex-workshop.viewer.pdf.internal.port": {
"type": "number",
"default": "0",
"markdownDescription": "Define the port to listen on for communicating with the internal viewer. The default value \"0\" means the port is chosen randomly by the application."
},
"latex-workshop.view.pdf.external.command": {
"type": "object",
"default": {
Expand Down
6 changes: 5 additions & 1 deletion src/components/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as http from 'http'
import * as ws from 'ws'
import * as fs from 'fs'
import * as path from 'path'
import * as vscode from 'vscode'

import {Extension} from '../main'
import {AddressInfo} from 'net'
Expand All @@ -15,7 +16,10 @@ export class Server {
constructor(extension: Extension) {
this.extension = extension
this.httpServer = http.createServer((request, response) => this.handler(request, response))
this.httpServer.listen(0, '127.0.0.1', undefined, (err: Error) => {
const configuration = vscode.workspace.getConfiguration('latex-workshop')
const viewerUrl = configuration.get('viewer.pdf.internal.url') as string
const viewerPort = configuration.get('viewer.pdf.internal.port') as number
this.httpServer.listen(viewerPort, viewerUrl, undefined, (err: Error) => {
if (err) {
this.extension.logger.addLogMessage(`Error creating LaTeX Workshop http server: ${err}.`)
} else {
Expand Down

0 comments on commit f2aed5c

Please sign in to comment.