Skip to content

Commit 8c6f7e9

Browse files
authored
fix: cover cases when 'wrote:' keyword not found in plain text reply mode #173 (#174)
1 parent a4a81fe commit 8c6f7e9

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

modules/compose.mjs

+21-7
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,28 @@ class ReplyWithHeader {
224224
rwhLogger.debug(textLines);
225225

226226
let locale = await rwhSettings.getHeaderLocale();
227+
rwhLogger.debug('locale -', locale);
228+
227229
let startPos = 0;
228230
let linesToDelete = 1;
229231
if (this.isReply) {
230-
let r = this._findPlainTextReplyInsertMarker(textLines, rwhI18n.i18n['wrote'][locale]);
231-
if (r.found) {
232-
startPos = r.startPos;
233-
} else { // fallback
234-
r = this._findPlainTextReplyInsertMarker(textLines, rwhI18n.i18n['wrote']['en-US']);
235-
startPos = r.found ? r.startPos : 0;
232+
// Reply insert marker by fallback order
233+
var lookupValues = new Array(
234+
rwhI18n.i18n['wrote'][locale],
235+
rwhI18n.i18n['wrote']['en-US'],
236+
rwhI18n.i18n['originalMessage'][locale],
237+
rwhI18n.i18n['originalMessage']['en-US'],
238+
);
239+
rwhLogger.debug('lookupValues -', lookupValues);
240+
241+
for (let idx in lookupValues) {
242+
let v = lookupValues[idx];
243+
let r = this._findPlainTextReplyInsertMarker(textLines, v);
244+
if (r.found) {
245+
rwhLogger.debug(`Found by the index: ${idx} value: ${v}`);
246+
startPos = r.startPos;
247+
break;
248+
}
236249
}
237250
} else if (this.isForward) {
238251
linesToDelete = rwhHeaders.length;
@@ -244,8 +257,9 @@ class ReplyWithHeader {
244257
}
245258
}
246259

260+
rwhLogger.debug('startPos -', startPos);
247261
if (startPos > 0) {
248-
rwhLogger.debug('startPos', startPos, textLines[startPos]);
262+
rwhLogger.debug('textLines: ', textLines[startPos]);
249263
textLines.splice(startPos, linesToDelete, ...rwhHeaders);
250264
}
251265

0 commit comments

Comments
 (0)