Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion app/renderer/inkFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function InkFile(anyPath, mainInkFile, isBrandNew, inkMode, events) {
// Default filename if creating a new file, and passed null to constructor
anyPath = anyPath || "Untitled.ink";

// Convert anyPath to a normalized path string
if (typeof anyPath === "object") {
anyPath = path.parse(anyPath);
}
anyPath = path.normalize(anyPath);

this.mainInkFile = mainInkFile;

// Obtain relative path by looking at main ink file
Expand Down Expand Up @@ -274,7 +280,7 @@ InkFile.prototype.addIncludeLine = function(relativePath) {

// Normally we allow the InkFileSymbols class to do this,
// but by the time it gets round to doing parsing, it'll be too late.
this.includes.push(relativePath);
this.includes.push(path.normalize(relativePath));
this.events.includesChanged();

// Insert the include text itself
Expand Down
4 changes: 3 additions & 1 deletion app/renderer/inkFileSymbols.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const assert = require("assert");
const path = require("path");
const TokenIterator = ace.require("ace/token_iterator").TokenIterator;
const _ = require("lodash");

Expand Down Expand Up @@ -154,7 +155,8 @@ InkFileSymbols.prototype.parse = function() {

// INCLUDE
else if( tok.type.indexOf("include.filepath") != -1 && tok.value.trim().length > 0 ) {
includes.push(tok.value);
// Normalize path when adding include
includes.push(path.normalize(tok.value));
lastIncludeRow = it.getCurrentTokenRow();
}

Expand Down
8 changes: 1 addition & 7 deletions app/renderer/inkProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ InkProject.prototype.addNewInclude = function(newIncludePath, addToMainInk) {
var newIncludeFile = this.createInkFile(newIncludePath || null, isBrandNew = true);

if( addToMainInk )
this.mainInk.addIncludeLine(newIncludeFile.relativePath());
this.mainInk.addIncludeLine(newIncludePath);

NavView.setFiles(this.mainInk, this.files);
EditorView.setFiles(this.files);
Expand All @@ -120,12 +120,6 @@ InkProject.prototype.refreshIncludes = function() {
return;

inkFile.includes.forEach(incPath => {

// fix include relative path on windows
// on windows path should be either always stored using the same folder separator (\\ or /).
// mixing them can create unexpected behaviours.
incPath = path.format(path.parse(incPath));

let alreadyDone = relPathsFromINCLUDEs.contains(incPath);

relPathsFromINCLUDEs.push(incPath);
Expand Down