Ver Fonte

auto-trim single-line clipboard contents (fixes #2677)

Eugene Pankov há 5 anos atrás
pai
commit
69a0b46a20

+ 18 - 18
terminus-terminal/src/api/baseTerminalTab.component.ts

@@ -308,25 +308,25 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
             data = data.replace(/\n/g, '\r')
         }
 
-        if (!this.alternateScreenActive && data.includes('\r') && this.config.store.terminal.warnOnMultilinePaste) {
-            const canTrim = !data.trim().includes('\r')
-            const buttons = canTrim ? ['Paste', 'Trim whitespace and paste', 'Cancel'] : ['Paste', 'Cancel']
-            const result = (await this.electron.showMessageBox(
-                this.hostApp.getWindow(),
-                {
-                    type: 'warning',
-                    detail: data,
-                    message: `Paste multiple lines?`,
-                    buttons,
-                    defaultId: 0,
-                    cancelId: buttons.length - 1,
+        if (!this.alternateScreenActive) {
+            data = data.trim()
+
+            if (data.includes('\r') && this.config.store.terminal.warnOnMultilinePaste) {
+                const buttons = ['Paste', 'Cancel']
+                const result = (await this.electron.showMessageBox(
+                    this.hostApp.getWindow(),
+                    {
+                        type: 'warning',
+                        detail: data,
+                        message: `Paste multiple lines?`,
+                        buttons,
+                        defaultId: 0,
+                        cancelId: 1,
+                    }
+                )).response
+                if (result === 1) {
+                    return
                 }
-            )).response
-            if (result === buttons.length - 1) {
-                return
-            }
-            if (result === 1) {
-                data = data.trim()
             }
         }
         this.sendInput(data)

+ 1 - 1
terminus-terminal/src/frontends/xtermFrontend.ts

@@ -124,7 +124,7 @@ export class XTermFrontend extends Frontend {
         }
 
         this.xterm.buffer.onBufferChange(() => {
-            const altBufferActive = this.xterm.buffer.active === this.xterm.buffer.alternate
+            const altBufferActive = this.xterm.buffer.active.type === 'alternate'
             this.alternateScreenActive.next(altBufferActive)
         })
     }