Skip to content

Commit

Permalink
feat(macro-prompts): preserve outer quotes
Browse files Browse the repository at this point in the history
Previously if you had a macro prompt such as the following, the modal title would display `Question`, not `"Question"`. However, in other projects (Klipperscreen and Fluidd), they will preserve those outer quotes and they will be included in the title. This change makes Mainsail consistent with the other implementations.

```
RESPOND TYPE=command MSG="action:prompt_begin \"Question\""
RESPOND TYPE=command MSG="action:prompt_button Button1|RESPOND MSG=\"Clicked it!\""
RESPOND TYPE=command MSG="action:prompt_show"
```
  • Loading branch information
ammmze committed Dec 10, 2024
1 parent ed8992e commit 7ece9a4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/dialogs/TheMacroPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class TheMacroPrompt extends Mixins(BaseMixin) {
private currentPrompt: ServerStateEventPrompt[] = []
// regex that extracts the type and message, omitting the wrapping double quotes of the message (if any)
private promptMessageExp =
/^\/\/ action:prompt_(?<type>[^\s]+) *(?:(?<quote>['"])(?<msg1>.*)\k<quote>|(?<msg2>.*))\s*$/
/^\/\/ action:prompt_(?<type>[^\s]+) *(?<msg>.*)$/
get events() {
return this.$store.state.server.events
Expand Down Expand Up @@ -95,7 +95,7 @@ export default class TheMacroPrompt extends Mixins(BaseMixin) {
break
}
const message = (match?.groups?.msg1 || match?.groups?.msg2 || '').trim()
const message = (match?.groups?.msg || '').trim()
// prepend the event to prompt events found in this chunk
promptEvents.unshift({
Expand Down

0 comments on commit 7ece9a4

Please sign in to comment.