@levu/snap 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.2] - 2026-02-26
9
+
10
+ ### Fixed
11
+ - Added Ghostty macOS fallback handling for `Shift+Enter` escape sequence variants like `13~`, so multiline prompts insert newline instead of echoing sequence text.
12
+ - Added regression coverage for the `13~` modified-enter sequence path.
13
+
8
14
  ## [0.3.1] - 2026-02-26
9
15
 
10
16
  ### Fixed
@@ -28,6 +28,7 @@ export const createMultilineTextPrompt = () => {
28
28
  let rawModeEnabled = false;
29
29
  let keypressListener;
30
30
  let ignoreNextLineEvent = false;
31
+ let expectingGhosttySequenceEcho = false;
31
32
  const cleanup = () => {
32
33
  if (keypressListener) {
33
34
  input.off('keypress', keypressListener);
@@ -62,6 +63,30 @@ export const createMultilineTextPrompt = () => {
62
63
  return rlLine;
63
64
  return currentLine;
64
65
  };
66
+ const isGhosttyShiftEnter = (str, key) => {
67
+ const sequence = String(key?.sequence ?? '');
68
+ if (sequence.includes('[13;2u'))
69
+ return true;
70
+ if (sequence.includes('[27;2;13~'))
71
+ return true;
72
+ if (sequence.endsWith('13~'))
73
+ return true;
74
+ if (sequence === '13~')
75
+ return true;
76
+ if (str === '~13')
77
+ return true;
78
+ if (str === '13~')
79
+ return true;
80
+ if (str === '\u001b[13;2u')
81
+ return true;
82
+ return false;
83
+ };
84
+ const insertNewline = () => {
85
+ lines.push(getLiveLine());
86
+ currentLine = '';
87
+ rl.line = '';
88
+ output.write(`\n${pc.dim('> ')}`);
89
+ };
65
90
  const showPrompt = () => {
66
91
  output.write(`\n${pc.dim('> ')}${currentLine}`);
67
92
  };
@@ -109,6 +134,13 @@ export const createMultilineTextPrompt = () => {
109
134
  ignoreNextLineEvent = false;
110
135
  return;
111
136
  }
137
+ if (expectingGhosttySequenceEcho) {
138
+ if (line === '13~' || line === '~13' || line === '[13;2u' || line === '\u001b[13;2u') {
139
+ expectingGhosttySequenceEcho = false;
140
+ return;
141
+ }
142
+ expectingGhosttySequenceEcho = false;
143
+ }
112
144
  const now = Date.now();
113
145
  // Check for double Enter to submit
114
146
  if (line === '' && now - lastEnterTime < DOUBLE_ENTER_TIMEOUT) {
@@ -171,14 +203,15 @@ export const createMultilineTextPrompt = () => {
171
203
  output.write(`${pc.dim('> ')}${currentLine}`);
172
204
  }
173
205
  }
206
+ else if (isGhosttyShiftEnter(str, key)) {
207
+ expectingGhosttySequenceEcho = true;
208
+ insertNewline();
209
+ }
174
210
  else if (key.name === 'enter' || key.name === 'return') {
175
211
  ignoreNextLineEvent = true;
176
212
  if (key.shift || key.alt) {
177
213
  // Shift+Enter / Alt+Enter inserts a new line.
178
- lines.push(getLiveLine());
179
- currentLine = '';
180
- rl.line = '';
181
- output.write(`\n${pc.dim('> ')}`);
214
+ insertNewline();
182
215
  return;
183
216
  }
184
217
  submit(lines.concat(getLiveLine()).join('\n'));
@@ -58,7 +58,7 @@ When `paste` is enabled, users can paste from clipboard using:
58
58
 
59
59
  Multi-line paste is automatically supported. Keyboard behavior:
60
60
  - `Enter` submits input
61
- - `Shift+Enter` inserts a newline (when your terminal reports Shift modifiers)
61
+ - `Shift+Enter` inserts a newline (including Ghostty sequence fallback variants)
62
62
  - `Alt+Enter` inserts a newline fallback
63
63
 
64
64
  ### confirm
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levu/snap",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "snap": "./dist/cli-entry.js"