Skip to content

Commit

Permalink
Fix #186
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Oct 7, 2024
1 parent b3a97e3 commit 1695f45
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@
"description": "Traces the communication between VS Code and the language server.",
"order": 20
},
"wollokLSP.repl.portNumber": {
"scope": "resource",
"type": "number",
"default": 3000,
"description": "Port number that will be used when running the REPL.",
"order": 25
},
"wollokLSP.dynamicDiagram.openDynamicDiagramOnRepl": {
"scope": "resource",
"type": "boolean",
Expand Down
7 changes: 4 additions & 3 deletions packages/client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
fsToShell,
} from './platform-string-utils'
import { COMMAND_RUN_ALL_TESTS, COMMAND_RUN_GAME, COMMAND_RUN_PROGRAM, COMMAND_RUN_TEST, COMMAND_START_REPL, wollokLSPExtensionCode } from './shared-definitions'
import { DEFAULT_PORT } from '../../server/src/settings'

export const subscribeWollokCommands = (context: ExtensionContext): void => {
context.subscriptions.push(registerCLICommand(COMMAND_START_REPL, startRepl))
Expand Down Expand Up @@ -66,16 +67,16 @@ const getCurrentFileName = (document: vscode.TextDocument | undefined) =>
const getFiles = (document: vscode.TextDocument | undefined): [ReturnType<typeof fsToShell>] | [] =>
document ? [fsToShell(document.uri.fsPath)] : []

const DYNAMIC_DIAGRAM_URI = 'http://localhost:3000/'

export const startRepl = (): Task => {
const currentDocument = window.activeTextEditor?.document
const wollokLSPConfiguration = workspace.getConfiguration(wollokLSPExtensionCode)
const dynamicDiagramDarkMode = wollokLSPConfiguration.get('dynamicDiagram.dynamicDiagramDarkMode') as boolean
const openDynamicDiagram = wollokLSPConfiguration.get('dynamicDiagram.openDynamicDiagramOnRepl') as boolean
const millisecondsToOpenDynamicDiagram = wollokLSPConfiguration.get('dynamicDiagram.millisecondsToOpenDynamicDiagram') as number
const portNumber = wollokLSPConfiguration.get('repl.portNumber') as number ?? DEFAULT_PORT
const DYNAMIC_DIAGRAM_URI = `http://localhost:${portNumber}/`

const cliCommands = [`repl`, ...getFiles(currentDocument), '--skipValidations', dynamicDiagramDarkMode ? '--darkMode' : '', openDynamicDiagram ? '': '--skipDiagram']
const cliCommands = [`repl`, ...getFiles(currentDocument), '--skipValidations', '--port', portNumber.toString(), dynamicDiagramDarkMode ? '--darkMode' : '', openDynamicDiagram ? '': '--skipDiagram']
// Terminate previous tasks
vscode.commands.executeCommand('workbench.action.terminal.killAll')
const replTask = wollokCLITask('repl', `Wollok Repl: ${getCurrentFileName(currentDocument)}`, cliCommands)
Expand Down
4 changes: 4 additions & 0 deletions packages/server/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { Connection } from 'vscode-languageserver/node'
import { wollokLSPExtensionCode } from './shared-definitions'
import { LANGUAGES } from 'wollok-ts'

Check failure on line 3 in packages/server/src/settings.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, lts/hydrogen)

Module '"wollok-ts"' has no exported member 'LANGUAGES'.

Check failure on line 3 in packages/server/src/settings.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, lts/hydrogen)

Module '"wollok-ts"' has no exported member 'LANGUAGES'.

export const DEFAULT_PORT = 3000

export interface WollokLSPSettings {
maxNumberOfProblems: number
language: LANGUAGES,
portNumber: number,
openDynamicDiagramOnRepl: boolean,
openInternalDynamicDiagram: boolean,
dynamicDiagramDarkMode: boolean,
Expand All @@ -25,6 +28,7 @@ const envLang = () => {
const defaultSettings: WollokLSPSettings = {
maxNumberOfProblems: 1000,
language: envLang(),
portNumber: DEFAULT_PORT,
openDynamicDiagramOnRepl: true,
openInternalDynamicDiagram: true,
dynamicDiagramDarkMode: true,
Expand Down

0 comments on commit 1695f45

Please sign in to comment.