mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
Add safety-space before pasting (#307)
* Add safety space when dropping in paths * Add safety space when dropping in paths
This commit is contained in:
parent
fa716246ea
commit
65cbc22d7c
1 changed files with 11 additions and 1 deletions
|
|
@ -689,11 +689,21 @@ export class Editor implements Component {
|
|||
const tabExpandedText = cleanText.replace(/\t/g, " ");
|
||||
|
||||
// Filter out non-printable characters except newlines
|
||||
const filteredText = tabExpandedText
|
||||
let filteredText = tabExpandedText
|
||||
.split("")
|
||||
.filter((char) => char === "\n" || char.charCodeAt(0) >= 32)
|
||||
.join("");
|
||||
|
||||
// If pasting a file path (starts with /, ~, or .) and the character before
|
||||
// the cursor is a word character, prepend a space for better readability
|
||||
if (/^[/~.]/.test(filteredText)) {
|
||||
const currentLine = this.state.lines[this.state.cursorLine] || "";
|
||||
const charBeforeCursor = this.state.cursorCol > 0 ? currentLine[this.state.cursorCol - 1] : "";
|
||||
if (charBeforeCursor && /\w/.test(charBeforeCursor)) {
|
||||
filteredText = ` ${filteredText}`;
|
||||
}
|
||||
}
|
||||
|
||||
// Split into lines
|
||||
const pastedLines = filteredText.split("\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue