Skip to content

Commit 2f983a1

Browse files
committed
Normalize multi-line prompts in commit message details
- prompts saved to disk should be stripped from new lines ├── apps │ └── editor │ └── src │ ├── commands │ │ ├── apply-response-command │ │ │ └── utils │ │ │ └── preview-handler.ts │ │ ├── code-at-cursor-command │ │ │ └── code-at-cursor-commands.ts │ │ ├── generate-commit-message-commands │ │ │ └── actions │ │ │ ├── get-prompt-data.ts │ │ │ └── run-generate-action.ts │ │ └── history-command │ │ └── actions │ │ └── restore-checkpoint.ts │ ├── services │ │ └── git-discard-file-watcher.ts │ └── utils │ └── commit-message-details.ts └── packages └── shared └── src └── utils └── simplify-prompt-symbols └── simplify-prompt-symbols.ts
1 parent b13afe2 commit 2f983a1

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-commands/actions/run-generate-action.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,12 @@ export const run_generate_action = async (params: {
573573
index == self.findIndex((sp) => sp.prompt == p.prompt)
574574
)
575575

576-
const relevant_prompts = all_relevant_prompts.filter((p) => p.prompt.trim() != '')
577-
const empty_prompts = all_relevant_prompts.filter((p) => p.prompt.trim() == '')
576+
const relevant_prompts = all_relevant_prompts.filter(
577+
(p) => p.prompt.trim() != ''
578+
)
579+
const empty_prompts = all_relevant_prompts.filter(
580+
(p) => p.prompt.trim() == ''
581+
)
578582

579583
const get_tree_text_if_applicable = async (
580584
selected_prompts: typeof relevant_prompts,

‎apps/editor/src/utils/commit-message-details.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export namespace CommitMessageDetails {
8080

8181
const simplified_prompt = simplify_prompt_symbols({
8282
prompt: params.prompt || ''
83-
})
83+
}).replace(/\r?\n|\r/g, ' ')
8484

8585
const normalize = (f: string) =>
8686
path.isAbsolute(f)
@@ -123,7 +123,9 @@ export namespace CommitMessageDetails {
123123
}) => {
124124
const all_prompts = load_all(params.extension_context)
125125
let changed = false
126-
const simplified_prompt = simplify_prompt_symbols({ prompt: params.prompt })
126+
const simplified_prompt = simplify_prompt_symbols({
127+
prompt: params.prompt
128+
}).replace(/\r?\n|\r/g, ' ')
127129

128130
for (const root in all_prompts) {
129131
const initial_count = all_prompts[root].length

0 commit comments

Comments
 (0)