Render files from their original path to resolve relative paths
This commit is contained in:
parent
b8a4a7423f
commit
fd89c4c3b6
3 changed files with 3 additions and 7 deletions
|
|
@ -14,7 +14,6 @@ export const getParentDir = (path: string) => {
|
||||||
let d = path.split('/').slice(0, -1).join('/');
|
let d = path.split('/').slice(0, -1).join('/');
|
||||||
return d === '' ? (path.startsWith('/') ? '/' : '.') : d;
|
return d === '' ? (path.startsWith('/') ? '/' : '.') : d;
|
||||||
}
|
}
|
||||||
export const getFileName = (path: string) => path.split('/').splice(-1)[0];
|
|
||||||
|
|
||||||
export function readDirAsArray(fs: FS, path: string): Promise<string[] | undefined> {
|
export function readDirAsArray(fs: FS, path: string): Promise<string[] | undefined> {
|
||||||
return new Promise((res, rej) => fs.readdir(path, (err, files) => err ? rej(err) : res(files)));
|
return new Promise((res, rej) => fs.readdir(path, (err, files) => err ? rej(err) : res(files)));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||||
|
|
||||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||||
import { getFileName, getParentDir } from '../fs/filesystem';
|
import { getParentDir } from '../fs/filesystem';
|
||||||
import { spawnOpenSCAD } from "./openscad-runner";
|
import { spawnOpenSCAD } from "./openscad-runner";
|
||||||
import { processMergedOutputs } from "./output-parser";
|
import { processMergedOutputs } from "./output-parser";
|
||||||
import { AbortablePromise, turnIntoDelayableExecution } from '../utils';
|
import { AbortablePromise, turnIntoDelayableExecution } from '../utils';
|
||||||
|
|
@ -14,7 +14,6 @@ export const checkSyntax =
|
||||||
// const timestamp = Date.now();
|
// const timestamp = Date.now();
|
||||||
|
|
||||||
source = '$preview=true;\n' + source;
|
source = '$preview=true;\n' + source;
|
||||||
sourcePath = getFileName(sourcePath);
|
|
||||||
|
|
||||||
const job = spawnOpenSCAD({
|
const job = spawnOpenSCAD({
|
||||||
inputs: [[sourcePath, source + '\n']],
|
inputs: [[sourcePath, source + '\n']],
|
||||||
|
|
@ -58,7 +57,6 @@ export const render =
|
||||||
prefixLines.push('$preview=true;');
|
prefixLines.push('$preview=true;');
|
||||||
}
|
}
|
||||||
source = [...prefixLines, source].join('\n');
|
source = [...prefixLines, source].join('\n');
|
||||||
sourcePath = getFileName(sourcePath);
|
|
||||||
|
|
||||||
const args = [
|
const args = [
|
||||||
sourcePath,
|
sourcePath,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
||||||
import { getFileName } from '../fs/filesystem';
|
|
||||||
import { MergedOutputs } from "./openscad-worker";
|
import { MergedOutputs } from "./openscad-worker";
|
||||||
|
|
||||||
const ignoredLogs = new Set([
|
const ignoredLogs = new Set([
|
||||||
|
|
@ -45,10 +44,10 @@ export function parseMergedOutputs(mergedOutputs: MergedOutputs, opts: MergedOut
|
||||||
severity: monaco.MarkerSeverity.Error
|
severity: monaco.MarkerSeverity.Error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const shiftSourceName = opts.shiftSourceLines && getFileName(opts.shiftSourceLines.sourcePath);
|
const shiftSourceName = opts.shiftSourceLines && opts.shiftSourceLines.sourcePath;
|
||||||
const getLine = (path: string, lineStr: string) => {
|
const getLine = (path: string, lineStr: string) => {
|
||||||
const line = Number(lineStr);
|
const line = Number(lineStr);
|
||||||
if (shiftSourceName && getFileName(path) == shiftSourceName) {
|
if (shiftSourceName && (path == shiftSourceName)) {
|
||||||
return line - opts.shiftSourceLines!.skipLines;
|
return line - opts.shiftSourceLines!.skipLines;
|
||||||
} else {
|
} else {
|
||||||
return line;
|
return line;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue