Skip to content

Commit

Permalink
fix(gui): copy strings without quotes (PR #2121)
Browse files Browse the repository at this point in the history
* Update AbstractCodeArea.java

In general, we need data, not text in code. But now every time you copy the highlighted text, you copy the highlighted quotes as well. This often results in an extra need to delete the quotation marks around the sides, which is confusing.
Now when copying selected highlighted text, quotes are not copied in.

* Update AbstractCodeArea.java

fix code format

* additional checks, move to common method

---------

Co-authored-by: Skylot <skylot@gmail.com>
  • Loading branch information
zhongqingsong and skylot committed Mar 16, 2024
1 parent 3599b24 commit 8760b4d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,15 @@ public String getWordUnderCaret() {

public @Nullable String getWordByPosition(int offset) {
Token token = getWordTokenAtOffset(offset);
if (token != null) {
return token.getLexeme();
if (token == null) {
return null;
}
return null;
String str = token.getLexeme();
int len = str.length();
if (len > 2 && str.startsWith("\"") && str.endsWith("\"")) {
return str.substring(1, len - 1);
}
return str;
}

/**
Expand Down

0 comments on commit 8760b4d

Please sign in to comment.