Skip to content

Commit

Permalink
lsp: Fix ${defaultBuildDir} variable expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Oct 21, 2024
1 parent a474a07 commit df58b81
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/esbonio/changes/918.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The language server no longer escapes `.` characters in filepaths when expanding the `${defaultBuildDir}` variable
resulting in weird filepaths
2 changes: 1 addition & 1 deletion lib/esbonio/esbonio/sphinx_agent/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def to_application_args(self, context: dict[str, Any]) -> dict[str, Any]:
continue

replacement = self.resolve_config_variable(match.group(1), context)
result = VARIABLE.sub(re.escape(replacement), value)
result = VARIABLE.sub(replacement.replace("\\", r"\\"), value)

setattr(self, name, result)

Expand Down
31 changes: 31 additions & 0 deletions lib/esbonio/tests/sphinx-agent/test_sa_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,21 @@ def test_cli_arg_handling(args: list[str], expected: dict[str, Any]):
"cacheDir": os.sep + os.sep.join(["path", "to", "cache"]),
},
),
(
["-M", "html", "src", "${defaultBuildDir}"],
application_args(
srcdir="src",
confdir="src",
outdir=os.sep + os.path.join("path", "to", ".cache", "<HASH>", "html"),
doctreedir=(
os.sep + os.path.join("path", "to", ".cache", "<HASH>", "doctrees")
),
buildername="html",
),
{
"cacheDir": os.sep + os.sep.join(["path", "to", ".cache"]),
},
),
(
["-b", "html", "src", "${defaultBuildDir}"],
application_args(
Expand All @@ -488,6 +503,22 @@ def test_cli_arg_handling(args: list[str], expected: dict[str, Any]):
"cacheDir": os.sep + os.sep.join(["path", "to", "cache"]),
},
),
(
["-b", "html", "src", "${defaultBuildDir}"],
application_args(
srcdir="src",
confdir="src",
outdir=os.sep + os.sep.join(["path", "to", ".cache", "<HASH>"]),
doctreedir=(
os.sep
+ os.path.join("path", "to", ".cache", r"<HASH>", ".doctrees")
),
buildername="html",
),
{
"cacheDir": os.sep + os.sep.join(["path", "to", ".cache"]),
},
),
],
)
def test_cli_default_build_dir(
Expand Down

0 comments on commit df58b81

Please sign in to comment.