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.
Commit
cd7f2ddc9884884bfa7cc3ae487386862216d214886db3907e89086c19d2630e
Parent
e6aaeb1b6df6424…
1 file changed
+11
-5
+11
-5
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -1350,29 +1350,35 @@ | ||
| 1350 | 1350 | */ |
| 1351 | 1351 | Chat.submitMessage = function f(){ |
| 1352 | 1352 | if(!f.spaces){ |
| 1353 | 1353 | f.spaces = /\s+$/; |
| 1354 | 1354 | f.markdownContinuation = /\\\s+$/; |
| 1355 | + f.spaces2 = /\s{3,}$/; | |
| 1355 | 1356 | } |
| 1356 | 1357 | this.setCurrentView(this.e.viewMessages); |
| 1357 | 1358 | const fd = new FormData(); |
| 1358 | 1359 | const fallback = {msg: this.inputValue()}; |
| 1359 | - var msg = fallback.msg.trim(); | |
| 1360 | + var msg = fallback.msg; | |
| 1360 | 1361 | 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 | |
| 1362 | 1363 | keep copy/paste from terminals, especially wide ones, from |
| 1363 | 1364 | forcing a horizontal scrollbar on all clients. This breaks |
| 1364 | 1365 | markdown's use of blackslash-space-space for paragraph |
| 1365 | 1366 | continuation, but *not* doing this affects all clients every |
| 1366 | 1367 | time someone pastes in console copy/paste from an affected |
| 1367 | 1368 | 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 | + */ | |
| 1370 | 1376 | const xmsg = msg.split('\n'); |
| 1371 | 1377 | xmsg.forEach(function(line,ndx){ |
| 1372 | 1378 | if(!f.markdownContinuation.test(line)){ |
| 1373 | - xmsg[ndx] = line.trimRight(); | |
| 1379 | + xmsg[ndx] = line.replace(f.spaces2, ' '); | |
| 1374 | 1380 | } |
| 1375 | 1381 | }); |
| 1376 | 1382 | msg = xmsg.join('\n'); |
| 1377 | 1383 | } |
| 1378 | 1384 | if(msg) fd.set('msg',msg); |
| 1379 | 1385 |
| --- 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 |