mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 20:44:08 +00:00
Properly sanitized pasted text from trailing spaces at end of line, fixes forced soft-wrap when too many consecutive trailing spaces
This commit is contained in:
1 parent
d59d990b70
commit
53f06ab388
2 files changed
+66
-4
No files matched your search
@@ -129,6 +129,9 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
|
||||
// ==================== SEARCH/REPLACE ====================
|
||||
public static final SearchReplaceBar searchBar = new SearchReplaceBar();
|
||||
|
||||
// ==================== PASTE SETTINGS ====================
|
||||
private static final int PASTE_TRAILING_WS_TRIM_THRESHOLD = 16;
|
||||
|
||||
// ==================== GO TO LINE ====================
|
||||
private final GoToLineDialog goToLineDialog = new GoToLineDialog();
|
||||
@@ -1311,9 +1314,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
if (!e.isPress() || !isActive.get())
|
||||
return;
|
||||
|
||||
String clipboard = NoppesStringUtils.getClipboardContents();
|
||||
if (clipboard == null)
|
||||
clipboard = "";
|
||||
String clipboardRaw = NoppesStringUtils.getClipboardContents();
|
||||
if (clipboardRaw == null)
|
||||
clipboardRaw = "";
|
||||
|
||||
boolean isLinePaste = lastCopyWasLine && lastCopiedLineText != null && clipboardRaw.equals(lastCopiedLineText);
|
||||
String clipboard = FormatHelper.sanitizeClipboard(clipboardRaw, PASTE_TRAILING_WS_TRIM_THRESHOLD);
|
||||
|
||||
if (selection.hasSelection()) {
|
||||
addText(clipboard);
|
||||
@@ -1323,7 +1329,6 @@ public class GuiScriptTextArea extends GuiNpcTextField {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isLinePaste = lastCopyWasLine && lastCopiedLineText != null && clipboard.equals(lastCopiedLineText);
|
||||
if (isLinePaste && container != null && container.lines != null) {
|
||||
LineData currentLine = selection.findCurrentLine(container.lines);
|
||||
if (currentLine != null) {
|
||||
|
||||
Reference in new issue
Block a user