Skip to content

Commit

Permalink
Refactor PushToVim
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Oct 23, 2024
1 parent 61395fa commit aeedbb4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/main/java/org/jabref/gui/push/PushToVim.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ public PushToApplicationSettings getSettings(PushToApplication application, Push

@Override
public void pushEntries(BibDatabaseContext database, List<BibEntry> entries, String keys) {
couldNotPush = false;
couldNotCall = false;
notDefined = false;

commandPath = preferences.getPushToApplicationPreferences().getCommandPaths().get(this.getDisplayName());

if ((commandPath == null) || commandPath.trim().isEmpty()) {
notDefined = true;
if (!determineCommandPath()) {
return;
}

Expand Down Expand Up @@ -110,14 +103,7 @@ public void onOperationCompleted() {

@Override
public void jumpToLine(Path fileName, int line, int column) {
couldNotPush = false;
couldNotCall = false;
notDefined = false;

commandPath = preferences.getPushToApplicationPreferences().getCommandPaths().get(this.getDisplayName());

if ((commandPath == null) || commandPath.trim().isEmpty()) {
notDefined = true;
if (!determineCommandPath()) {
return;
}

Expand Down Expand Up @@ -157,6 +143,20 @@ public void jumpToLine(Path fileName, int line, int column) {
}
}

private boolean determineCommandPath() {
couldNotPush = false;
couldNotCall = false;
notDefined = false;

commandPath = preferences.getPushToApplicationPreferences().getCommandPaths().get(this.getDisplayName());

if ((commandPath == null) || commandPath.trim().isEmpty()) {
notDefined = true;
return false;
}
return true;
}

@Override
protected String[] jumpToLineCommandlineArguments(Path fileName, int line, int column) {
return new String[] {commandPath, "+%s".formatted(line), fileName.toString(), "+\"normal %s|\"".formatted(column)};
Expand Down

0 comments on commit aeedbb4

Please sign in to comment.