-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Copy cite command should respect preferences
Fixes #10615
- Loading branch information
1 parent
d9ebef5
commit f85c393
Showing
10 changed files
with
122 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/org/jabref/logic/push/CitationCommandString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.jabref.logic.push; | ||
|
||
public record CitationCommandString( | ||
String prefix, | ||
String delimiter, | ||
String suffix) { | ||
private static final String CITE_KEY1 = "key1"; | ||
private static final String CITE_KEY2 = "key2"; | ||
|
||
@Override | ||
public String toString() { | ||
return prefix + CITE_KEY1 + delimiter + CITE_KEY2 + suffix; | ||
} | ||
|
||
public static CitationCommandString from(String completeCiteCommand) { | ||
|
||
int indexKey1 = completeCiteCommand.indexOf(CITE_KEY1); | ||
int indexKey2 = completeCiteCommand.indexOf(CITE_KEY2); | ||
if (indexKey1 < 0 || indexKey2 < 0 || indexKey2 < (indexKey1 + CITE_KEY1.length())) { | ||
return new CitationCommandString("", "", ""); | ||
} | ||
|
||
String prefix = completeCiteCommand.substring(0, indexKey1); | ||
String delim = completeCiteCommand.substring(completeCiteCommand.lastIndexOf(CITE_KEY1) + CITE_KEY1.length(), indexKey2); | ||
String suffix = completeCiteCommand.substring(completeCiteCommand.lastIndexOf(CITE_KEY2) + CITE_KEY2.length()); | ||
return new CitationCommandString(prefix, delim, suffix); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.