Fossil SCM

In /chat, change the EOL whitespace-stripping policy to retain up to 2 spaces, only stripping after the 3rd, to avoid breaking certain markdown constructs. Per /chat discussion.

stephan 2022-06-08 15:17 trunk
Commit cd7f2ddc9884884bfa7cc3ae487386862216d214886db3907e89086c19d2630e
1 file changed +11 -5
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1350,29 +1350,35 @@
13501350
*/
13511351
Chat.submitMessage = function f(){
13521352
if(!f.spaces){
13531353
f.spaces = /\s+$/;
13541354
f.markdownContinuation = /\\\s+$/;
1355
+ f.spaces2 = /\s{3,}$/;
13551356
}
13561357
this.setCurrentView(this.e.viewMessages);
13571358
const fd = new FormData();
13581359
const fallback = {msg: this.inputValue()};
1359
- var msg = fallback.msg.trim();
1360
+ var msg = fallback.msg;
13601361
if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
1361
- /* Cosmetic: trim whitespace from the ends of lines to try to
1362
+ /* Cosmetic: trim most whitespace from the ends of lines to try to
13621363
keep copy/paste from terminals, especially wide ones, from
13631364
forcing a horizontal scrollbar on all clients. This breaks
13641365
markdown's use of blackslash-space-space for paragraph
13651366
continuation, but *not* doing this affects all clients every
13661367
time someone pastes in console copy/paste from an affected
13671368
platform. We seem to have narrowed to the console pasting
1368
- problem to users of tmux. Most consoles don't behave
1369
- that way. */
1369
+ problem to users of tmux together with certain apps (vim, at
1370
+ a minimum). Most consoles don't behave that way.
1371
+
1372
+ We retain two trailing spaces so that markdown conventions
1373
+ which use end-of-line spacing aren't broken by this
1374
+ stripping.
1375
+ */
13701376
const xmsg = msg.split('\n');
13711377
xmsg.forEach(function(line,ndx){
13721378
if(!f.markdownContinuation.test(line)){
1373
- xmsg[ndx] = line.trimRight();
1379
+ xmsg[ndx] = line.replace(f.spaces2, ' ');
13741380
}
13751381
});
13761382
msg = xmsg.join('\n');
13771383
}
13781384
if(msg) fd.set('msg',msg);
13791385
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1350,29 +1350,35 @@
1350 */
1351 Chat.submitMessage = function f(){
1352 if(!f.spaces){
1353 f.spaces = /\s+$/;
1354 f.markdownContinuation = /\\\s+$/;
 
1355 }
1356 this.setCurrentView(this.e.viewMessages);
1357 const fd = new FormData();
1358 const fallback = {msg: this.inputValue()};
1359 var msg = fallback.msg.trim();
1360 if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
1361 /* Cosmetic: trim whitespace from the ends of lines to try to
1362 keep copy/paste from terminals, especially wide ones, from
1363 forcing a horizontal scrollbar on all clients. This breaks
1364 markdown's use of blackslash-space-space for paragraph
1365 continuation, but *not* doing this affects all clients every
1366 time someone pastes in console copy/paste from an affected
1367 platform. We seem to have narrowed to the console pasting
1368 problem to users of tmux. Most consoles don't behave
1369 that way. */
 
 
 
 
 
1370 const xmsg = msg.split('\n');
1371 xmsg.forEach(function(line,ndx){
1372 if(!f.markdownContinuation.test(line)){
1373 xmsg[ndx] = line.trimRight();
1374 }
1375 });
1376 msg = xmsg.join('\n');
1377 }
1378 if(msg) fd.set('msg',msg);
1379
--- src/fossil.page.chat.js
+++ src/fossil.page.chat.js
@@ -1350,29 +1350,35 @@
1350 */
1351 Chat.submitMessage = function f(){
1352 if(!f.spaces){
1353 f.spaces = /\s+$/;
1354 f.markdownContinuation = /\\\s+$/;
1355 f.spaces2 = /\s{3,}$/;
1356 }
1357 this.setCurrentView(this.e.viewMessages);
1358 const fd = new FormData();
1359 const fallback = {msg: this.inputValue()};
1360 var msg = fallback.msg;
1361 if(msg && (msg.indexOf('\n')>0 || f.spaces.test(msg))){
1362 /* Cosmetic: trim most whitespace from the ends of lines to try to
1363 keep copy/paste from terminals, especially wide ones, from
1364 forcing a horizontal scrollbar on all clients. This breaks
1365 markdown's use of blackslash-space-space for paragraph
1366 continuation, but *not* doing this affects all clients every
1367 time someone pastes in console copy/paste from an affected
1368 platform. We seem to have narrowed to the console pasting
1369 problem to users of tmux together with certain apps (vim, at
1370 a minimum). Most consoles don't behave that way.
1371
1372 We retain two trailing spaces so that markdown conventions
1373 which use end-of-line spacing aren't broken by this
1374 stripping.
1375 */
1376 const xmsg = msg.split('\n');
1377 xmsg.forEach(function(line,ndx){
1378 if(!f.markdownContinuation.test(line)){
1379 xmsg[ndx] = line.replace(f.spaces2, ' ');
1380 }
1381 });
1382 msg = xmsg.join('\n');
1383 }
1384 if(msg) fd.set('msg',msg);
1385

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button