fix: focus on new editor action and refresh editor actions on apply (#518)

This commit is contained in:
Phil 2024-04-27 22:49:36 +02:00 committed by GitHub
parent 8de72b3301
commit 1415f387ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -28,7 +28,6 @@ import ee.carlrobert.codegpt.ui.UIUtil;
import java.awt.Dimension;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@ -191,7 +190,12 @@ public class ConfigurationComponent {
private JPanel createTablePanel() {
return ToolbarDecorator.createDecorator(table)
.setPreferredSize(new Dimension(table.getPreferredSize().width, 140))
.setAddAction(anActionButton -> getModel().addRow(new Object[]{"", ""}))
.setAddAction(anActionButton -> {
getModel().addRow(new Object[]{"", ""});
int lastRowIndex = getModel().getRowCount() - 1;
table.changeSelection(lastRowIndex, 0, false, false);
table.editCellAt(lastRowIndex, 0);
})
.setRemoveAction(anActionButton -> getModel().removeRow(table.getSelectedRow()))
.disableUpAction()
.disableDownAction()

View file

@ -4,6 +4,7 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.util.Disposer;
import ee.carlrobert.codegpt.CodeGPTBundle;
import ee.carlrobert.codegpt.actions.editor.EditorActionsUtil;
import javax.swing.JComponent;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@ -39,6 +40,7 @@ public class ConfigurationConfigurable implements Configurable {
@Override
public void apply() {
ConfigurationSettings.getInstance().loadState(component.getCurrentFormState());
EditorActionsUtil.refreshActions();
}
@Override