🤖 codex: preserve spacing after inline directives (issue-telegram-inline-spacing)
This commit is contained in:
committed by
Peter Steinberger
parent
4e92ccc0dd
commit
43545a4864
@@ -107,6 +107,12 @@ describe("extractModelDirective", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("edge cases", () => {
|
describe("edge cases", () => {
|
||||||
|
it("preserves spacing when /model is followed by a path segment", () => {
|
||||||
|
const result = extractModelDirective("thats not /model gpt-5/tmp/hello");
|
||||||
|
expect(result.hasDirective).toBe(true);
|
||||||
|
expect(result.cleaned).toBe("thats not /hello");
|
||||||
|
});
|
||||||
|
|
||||||
it("handles alias with special regex characters", () => {
|
it("handles alias with special regex characters", () => {
|
||||||
const result = extractModelDirective("/test.alias", {
|
const result = extractModelDirective("/test.alias", {
|
||||||
aliases: ["test.alias"],
|
aliases: ["test.alias"],
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export function extractModelDirective(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cleaned = match
|
const cleaned = match
|
||||||
? body.replace(match[0], "").replace(/\s+/g, " ").trim()
|
? body.replace(match[0], " ").replace(/\s+/g, " ").trim()
|
||||||
: body.trim();
|
: body.trim();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const extractLevelDirective = <T>(
|
|||||||
const level = normalize(rawLevel);
|
const level = normalize(rawLevel);
|
||||||
const cleaned = body
|
const cleaned = body
|
||||||
.slice(0, match.start)
|
.slice(0, match.start)
|
||||||
|
.concat(" ")
|
||||||
.concat(body.slice(match.end))
|
.concat(body.slice(match.end))
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
@@ -76,7 +77,7 @@ const extractSimpleDirective = (
|
|||||||
new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)(?:\\s*:\\s*)?`, "i"),
|
new RegExp(`(?:^|\\s)\\/(?:${namePattern})(?=$|\\s|:)(?:\\s*:\\s*)?`, "i"),
|
||||||
);
|
);
|
||||||
const cleaned = match
|
const cleaned = match
|
||||||
? body.replace(match[0], "").replace(/\s+/g, " ").trim()
|
? body.replace(match[0], " ").replace(/\s+/g, " ").trim()
|
||||||
: body.trim();
|
: body.trim();
|
||||||
return {
|
return {
|
||||||
cleaned,
|
cleaned,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ export function extractQueueDirective(body?: string): {
|
|||||||
const args = body.slice(argsStart);
|
const args = body.slice(argsStart);
|
||||||
const parsed = parseQueueDirectiveArgs(args);
|
const parsed = parseQueueDirectiveArgs(args);
|
||||||
const cleanedRaw =
|
const cleanedRaw =
|
||||||
body.slice(0, start) + body.slice(argsStart + parsed.consumed);
|
body.slice(0, start) + " " + body.slice(argsStart + parsed.consumed);
|
||||||
const cleaned = cleanedRaw.replace(/\s+/g, " ").trim();
|
const cleaned = cleanedRaw.replace(/\s+/g, " ").trim();
|
||||||
return {
|
return {
|
||||||
cleaned,
|
cleaned,
|
||||||
|
|||||||
Reference in New Issue
Block a user