From 0db7210ecf2cf6eb382982b88d8edc8c8c09bc2b Mon Sep 17 00:00:00 2001 From: Ada Null Date: Sun, 10 May 2026 16:01:08 +0100 Subject: [PATCH 1/2] Using path.normalize() instead of path.format(path.parse()) to fix mixed slashes on Windows --- app/renderer/inkProject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/renderer/inkProject.js b/app/renderer/inkProject.js index 73bf612d..f84790fa 100644 --- a/app/renderer/inkProject.js +++ b/app/renderer/inkProject.js @@ -124,7 +124,7 @@ InkProject.prototype.refreshIncludes = function() { // 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)); + incPath = path.normalize(incPath); let alreadyDone = relPathsFromINCLUDEs.contains(incPath); From 2a41c6261f72f90d9f5b48d2aa01ec8bc38718b7 Mon Sep 17 00:00:00 2001 From: Ada Null Date: Sun, 10 May 2026 17:33:51 +0100 Subject: [PATCH 2/2] Storing all path data in InkFiles as normalized paths, including includes --- app/renderer/inkFile.js | 8 +++++++- app/renderer/inkFileSymbols.js | 4 +++- app/renderer/inkProject.js | 8 +------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/renderer/inkFile.js b/app/renderer/inkFile.js index dbc1bf07..7a32a614 100644 --- a/app/renderer/inkFile.js +++ b/app/renderer/inkFile.js @@ -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 @@ -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 diff --git a/app/renderer/inkFileSymbols.js b/app/renderer/inkFileSymbols.js index f31e1782..d893ed7c 100644 --- a/app/renderer/inkFileSymbols.js +++ b/app/renderer/inkFileSymbols.js @@ -1,4 +1,5 @@ const assert = require("assert"); +const path = require("path"); const TokenIterator = ace.require("ace/token_iterator").TokenIterator; const _ = require("lodash"); @@ -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(); } diff --git a/app/renderer/inkProject.js b/app/renderer/inkProject.js index f84790fa..b5bcb1ef 100644 --- a/app/renderer/inkProject.js +++ b/app/renderer/inkProject.js @@ -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); @@ -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.normalize(incPath); - let alreadyDone = relPathsFromINCLUDEs.contains(incPath); relPathsFromINCLUDEs.push(incPath);