| 405 | |
| 406 | // Yank the selection; always exits; collapses the selection; set @yankedText and return it. |
| 407 | yank(args) { |
| 408 | if (args == null) { |
| 409 | args = {}; |
| 410 | } |
| 411 | this.yankedText = this.selection.toString(); |
| 412 | this.exit(); |
| 413 | HUD.copyToClipboard(this.yankedText); |
| 414 | |
| 415 | let message = this.yankedText.replace(/\s+/g, " "); |
| 416 | if (15 < this.yankedText.length) { |
| 417 | message = message.slice(0, 12) + "..."; |
| 418 | } |
| 419 | const plural = this.yankedText.length === 1 ? "" : "s"; |
| 420 | HUD.show(`Yanked ${this.yankedText.length} character${plural}: \"${message}\".`, 2500); |
| 421 | |
| 422 | return this.yankedText; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // A movement can be either a string or a function. |