mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-28 16:34:10 +02:00
parent
bf0fba9c58
commit
832c1c0be3
.idea/fileTemplates/code
src
main/java/com/maddyhome/idea/vim
EventFacade.javaRegisterActions.javaVimPlugin.java
ex/vimscript
extension
group
ChangeGroup.javaDigraphGroup.javaEditorGroup.javaFileGroup.javaKeyGroup.javaMarkGroup.javaMotionGroup.ktProcessGroup.javaRegisterGroup.javaSearchGroup.javaVimJumpServiceImpl.ktWindowGroup.java
helper
icons
listener
mark
newapi
package-info.javaregexp
statistic
ui
vimscript
model
parser
test/java
org/jetbrains/plugins/ideavim/action
ui
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
action/motion/updown
api
EngineEditorHelper.ktVimChangeGroup.ktVimChangeGroupBase.ktVimCommandGroupBase.ktVimDigraphGroupBase.ktVimJumpServiceBase.ktVimOptionGroupBase.ktVimSearchHelper.ktVimSearchHelperBase.kt
extension
key
regexp
vimscript/model
@ -1 +1 @@
|
|||||||
com.maddyhome.idea.vim.helper.MessageHelper.message("${PROPERTY_KEY}",${PARAMETERS})
|
com.maddyhome.idea.vim.helper.MessageHelper.message("${PROPERTY_KEY}", ${PARAMETERS})
|
@ -30,17 +30,14 @@ import java.awt.event.MouseListener;
|
|||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class EventFacade {
|
public class EventFacade {
|
||||||
private static final @NotNull
|
private static final @NotNull EventFacade ourInstance = new EventFacade();
|
||||||
EventFacade ourInstance = new EventFacade();
|
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable TypedActionHandler myOriginalTypedActionHandler;
|
||||||
TypedActionHandler myOriginalTypedActionHandler;
|
|
||||||
|
|
||||||
private EventFacade() {
|
private EventFacade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull EventFacade getInstance() {
|
||||||
EventFacade getInstance() {
|
|
||||||
return ourInstance;
|
return ourInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +143,7 @@ public class EventFacade {
|
|||||||
editor.getSelectionModel().removeSelectionListener(listener);
|
editor.getSelectionModel().removeSelectionListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull
|
private @NotNull TypedAction getTypedAction() {
|
||||||
TypedAction getTypedAction() {
|
|
||||||
return TypedAction.getInstance();
|
return TypedAction.getInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,15 +43,13 @@ public class RegisterActions {
|
|||||||
}, VimPlugin.getInstance());
|
}, VimPlugin.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable
|
public static @Nullable EditorActionHandlerBase findAction(@NotNull String id) {
|
||||||
EditorActionHandlerBase findAction(@NotNull String id) {
|
|
||||||
return VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream()
|
return VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream()
|
||||||
.filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst().map(ActionBeanClass::getInstance)
|
.filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst().map(ActionBeanClass::getInstance)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull EditorActionHandlerBase findActionOrDie(@NotNull String id) {
|
||||||
EditorActionHandlerBase findActionOrDie(@NotNull String id) {
|
|
||||||
EditorActionHandlerBase action = findAction(id);
|
EditorActionHandlerBase action = findAction(id);
|
||||||
if (action == null) throw new RuntimeException("Action " + id + " is not registered");
|
if (action == null) throw new RuntimeException("Action " + id + " is not registered");
|
||||||
return action;
|
return action;
|
||||||
@ -67,7 +65,7 @@ public class RegisterActions {
|
|||||||
private static void registerVimCommandActions() {
|
private static void registerVimCommandActions() {
|
||||||
KeyGroup parser = VimPlugin.getKey();
|
KeyGroup parser = VimPlugin.getKey();
|
||||||
VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream().map(IjVimActionsInitiator::new)
|
VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream().map(IjVimActionsInitiator::new)
|
||||||
.forEach(parser::registerCommandAction);
|
.forEach(parser::registerCommandAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerEmptyShortcuts() {
|
private static void registerEmptyShortcuts() {
|
||||||
|
@ -70,8 +70,7 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
VimInjectorKt.setInjector(new IjVimInjector());
|
VimInjectorKt.setInjector(new IjVimInjector());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull VimState state = new VimState();
|
||||||
VimState state = new VimState();
|
|
||||||
public Disposable onOffDisposable;
|
public Disposable onOffDisposable;
|
||||||
private int previousStateVersion = 0;
|
private int previousStateVersion = 0;
|
||||||
private String previousKeyMap = "";
|
private String previousKeyMap = "";
|
||||||
@ -87,160 +86,130 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
/**
|
/**
|
||||||
* @return NotificationService as applicationService if project is null and projectService otherwise
|
* @return NotificationService as applicationService if project is null and projectService otherwise
|
||||||
*/
|
*/
|
||||||
public static @NotNull
|
public static @NotNull NotificationService getNotifications(@Nullable Project project) {
|
||||||
NotificationService getNotifications(@Nullable Project project) {
|
|
||||||
if (project == null) {
|
if (project == null) {
|
||||||
return ApplicationManager.getApplication().getService(NotificationService.class);
|
return ApplicationManager.getApplication().getService(NotificationService.class);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return project.getService(NotificationService.class);
|
return project.getService(NotificationService.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VimState getVimState() {
|
||||||
VimState getVimState() {
|
|
||||||
return getInstance().state;
|
return getInstance().state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull MotionGroup getMotion() {
|
||||||
MotionGroup getMotion() {
|
|
||||||
return ApplicationManager.getApplication().getService(MotionGroup.class);
|
return ApplicationManager.getApplication().getService(MotionGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull XMLGroup getXML() {
|
||||||
XMLGroup getXML() {
|
|
||||||
return ApplicationManager.getApplication().getService(XMLGroup.class);
|
return ApplicationManager.getApplication().getService(XMLGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull ChangeGroup getChange() {
|
||||||
ChangeGroup getChange() {
|
return ((ChangeGroup)VimInjectorKt.getInjector().getChangeGroup());
|
||||||
return ((ChangeGroup) VimInjectorKt.getInjector().getChangeGroup());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull CommandGroup getCommand() {
|
||||||
CommandGroup getCommand() {
|
|
||||||
return ApplicationManager.getApplication().getService(CommandGroup.class);
|
return ApplicationManager.getApplication().getService(CommandGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated // "Please use `injector.markService` instead"
|
@Deprecated // "Please use `injector.markService` instead"
|
||||||
@ApiStatus.ScheduledForRemoval(inVersion = "2.3")
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.3")
|
||||||
public static @NotNull
|
public static @NotNull MarkGroup getMark() {
|
||||||
MarkGroup getMark() {
|
|
||||||
return ApplicationManager.getApplication().getService(MarkGroup.class);
|
return ApplicationManager.getApplication().getService(MarkGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull RegisterGroup getRegister() {
|
||||||
RegisterGroup getRegister() {
|
return ((RegisterGroup)VimInjectorKt.getInjector().getRegisterGroup());
|
||||||
return ((RegisterGroup) VimInjectorKt.getInjector().getRegisterGroup());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull FileGroup getFile() {
|
||||||
FileGroup getFile() {
|
return (FileGroup)VimInjectorKt.getInjector().getFile();
|
||||||
return (FileGroup) VimInjectorKt.getInjector().getFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull SearchGroup getSearch() {
|
||||||
SearchGroup getSearch() {
|
|
||||||
return ApplicationManager.getApplication().getService(SearchGroup.class);
|
return ApplicationManager.getApplication().getService(SearchGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable
|
public static @Nullable SearchGroup getSearchIfCreated() {
|
||||||
SearchGroup getSearchIfCreated() {
|
|
||||||
return ApplicationManager.getApplication().getServiceIfCreated(SearchGroup.class);
|
return ApplicationManager.getApplication().getServiceIfCreated(SearchGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull ProcessGroup getProcess() {
|
||||||
ProcessGroup getProcess() {
|
return ((ProcessGroup)VimInjectorKt.getInjector().getProcessGroup());
|
||||||
return ((ProcessGroup) VimInjectorKt.getInjector().getProcessGroup());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull MacroGroup getMacro() {
|
||||||
MacroGroup getMacro() {
|
return (MacroGroup)VimInjectorKt.getInjector().getMacro();
|
||||||
return (MacroGroup) VimInjectorKt.getInjector().getMacro();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull DigraphGroup getDigraph() {
|
||||||
DigraphGroup getDigraph() {
|
return (DigraphGroup)VimInjectorKt.getInjector().getDigraphGroup();
|
||||||
return (DigraphGroup) VimInjectorKt.getInjector().getDigraphGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull HistoryGroup getHistory() {
|
||||||
HistoryGroup getHistory() {
|
|
||||||
return ApplicationManager.getApplication().getService(HistoryGroup.class);
|
return ApplicationManager.getApplication().getService(HistoryGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull KeyGroup getKey() {
|
||||||
KeyGroup getKey() {
|
return ((KeyGroup)VimInjectorKt.getInjector().getKeyGroup());
|
||||||
return ((KeyGroup) VimInjectorKt.getInjector().getKeyGroup());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable
|
public static @Nullable KeyGroup getKeyIfCreated() {
|
||||||
KeyGroup getKeyIfCreated() {
|
return ((KeyGroup)ApplicationManager.getApplication().getServiceIfCreated(VimKeyGroup.class));
|
||||||
return ((KeyGroup) ApplicationManager.getApplication().getServiceIfCreated(VimKeyGroup.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull WindowGroup getWindow() {
|
||||||
WindowGroup getWindow() {
|
return ((WindowGroup)VimInjectorKt.getInjector().getWindow());
|
||||||
return ((WindowGroup) VimInjectorKt.getInjector().getWindow());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull EditorGroup getEditor() {
|
||||||
EditorGroup getEditor() {
|
|
||||||
return ApplicationManager.getApplication().getService(EditorGroup.class);
|
return ApplicationManager.getApplication().getService(EditorGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable
|
public static @Nullable EditorGroup getEditorIfCreated() {
|
||||||
EditorGroup getEditorIfCreated() {
|
|
||||||
return ApplicationManager.getApplication().getServiceIfCreated(EditorGroup.class);
|
return ApplicationManager.getApplication().getServiceIfCreated(EditorGroup.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VisualMotionGroup getVisualMotion() {
|
||||||
VisualMotionGroup getVisualMotion() {
|
return (VisualMotionGroup)VimInjectorKt.getInjector().getVisualMotionGroup();
|
||||||
return (VisualMotionGroup) VimInjectorKt.getInjector().getVisualMotionGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull YankGroupBase getYank() {
|
||||||
YankGroupBase getYank() {
|
return (YankGroupBase)VimInjectorKt.getInjector().getYank();
|
||||||
return (YankGroupBase) VimInjectorKt.getInjector().getYank();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull PutGroup getPut() {
|
||||||
PutGroup getPut() {
|
return (PutGroup)VimInjectorKt.getInjector().getPut();
|
||||||
return (PutGroup) VimInjectorKt.getInjector().getPut();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VariableService getVariableService() {
|
||||||
VariableService getVariableService() {
|
|
||||||
return ApplicationManager.getApplication().getService(VariableService.class);
|
return ApplicationManager.getApplication().getService(VariableService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VimOptionGroup getOptionGroup() {
|
||||||
VimOptionGroup getOptionGroup() {
|
|
||||||
return VimInjectorKt.getInjector().getOptionGroup();
|
return VimInjectorKt.getInjector().getOptionGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Deprecated: Use getOptionGroup */
|
||||||
* Deprecated: Use getOptionGroup
|
|
||||||
*/
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// Used by which-key 0.8.0, IdeaVimExtension 1.6.5 + 1.6.8
|
// Used by which-key 0.8.0, IdeaVimExtension 1.6.5 + 1.6.8
|
||||||
public static @NotNull
|
public static @NotNull OptionService getOptionService() {
|
||||||
OptionService getOptionService() {
|
|
||||||
return VimInjectorKt.getInjector().getOptionService();
|
return VimInjectorKt.getInjector().getOptionService();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull NotificationService getNotifications() {
|
||||||
NotificationService getNotifications() {
|
|
||||||
return getNotifications(null);
|
return getNotifications(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull PluginId getPluginId() {
|
||||||
PluginId getPluginId() {
|
|
||||||
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
return PluginId.getId(IDEAVIM_PLUGIN_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull String getVersion() {
|
||||||
String getVersion() {
|
|
||||||
final IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(getPluginId());
|
final IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(getPluginId());
|
||||||
return plugin != null ? plugin.getVersion() : "SNAPSHOT";
|
return plugin != null ? plugin.getVersion() : "SNAPSHOT";
|
||||||
}
|
}
|
||||||
@ -284,8 +253,7 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
VimInjectorKt.getInjector().getMessages().showStatusBarMessage(null, msg);
|
VimInjectorKt.getInjector().getMessages().showStatusBarMessage(null, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VimPlugin getInstance() {
|
||||||
VimPlugin getInstance() {
|
|
||||||
return ApplicationManager.getApplication().getService(VimPlugin.class);
|
return ApplicationManager.getApplication().getService(VimPlugin.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +264,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
Application application = ApplicationManager.getApplication();
|
Application application = ApplicationManager.getApplication();
|
||||||
if (application.isUnitTestMode()) {
|
if (application.isUnitTestMode()) {
|
||||||
application.invokeAndWait(this::turnOnPlugin);
|
application.invokeAndWait(this::turnOnPlugin);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
application.invokeLater(this::turnOnPlugin);
|
application.invokeLater(this::turnOnPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -400,7 +369,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
if (showNotification && VimPlugin.getNotifications().enableRepeatingMode() == Messages.YES) {
|
if (showNotification && VimPlugin.getNotifications().enableRepeatingMode() == Messages.YES) {
|
||||||
getEditor().setKeyRepeat(true);
|
getEditor().setKeyRepeat(true);
|
||||||
keyRepeat.setEnabled(true);
|
keyRepeat.setEnabled(true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
getEditor().setKeyRepeat(false);
|
getEditor().setKeyRepeat(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +402,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
if (state != null) {
|
if (state != null) {
|
||||||
try {
|
try {
|
||||||
previousStateVersion = Integer.parseInt(state.getAttributeValue("version"));
|
previousStateVersion = Integer.parseInt(state.getAttributeValue("version"));
|
||||||
} catch (NumberFormatException ignored) {
|
}
|
||||||
|
catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
enabled = Boolean.parseBoolean(state.getAttributeValue("enabled"));
|
enabled = Boolean.parseBoolean(state.getAttributeValue("enabled"));
|
||||||
previousKeyMap = state.getAttributeValue("keymap");
|
previousKeyMap = state.getAttributeValue("keymap");
|
||||||
@ -461,8 +432,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
|
|||||||
private void legacyStateLoading(@NotNull Element element) {
|
private void legacyStateLoading(@NotNull Element element) {
|
||||||
if (previousStateVersion > 0 && previousStateVersion < 5) {
|
if (previousStateVersion > 0 && previousStateVersion < 5) {
|
||||||
// Migrate settings from 4 to 5 version
|
// Migrate settings from 4 to 5 version
|
||||||
((VimMarkServiceImpl) VimInjectorKt.getInjector().getMarkService()).loadState(element);
|
((VimMarkServiceImpl)VimInjectorKt.getInjector().getMarkService()).loadState(element);
|
||||||
((VimJumpServiceImpl) VimInjectorKt.getInjector().getJumpService()).loadState(element);
|
((VimJumpServiceImpl)VimInjectorKt.getInjector().getJumpService()).loadState(element);
|
||||||
getRegister().readData(element);
|
getRegister().readData(element);
|
||||||
getSearch().readData(element);
|
getSearch().readData(element);
|
||||||
getHistory().readData(element);
|
getHistory().readData(element);
|
||||||
|
@ -28,13 +28,11 @@ public class VimScriptGlobalEnvironment {
|
|||||||
private VimScriptGlobalEnvironment() {
|
private VimScriptGlobalEnvironment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull VimScriptGlobalEnvironment getInstance() {
|
||||||
VimScriptGlobalEnvironment getInstance() {
|
|
||||||
return ourInstance;
|
return ourInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull
|
public @NotNull Map<String, Object> getVariables() {
|
||||||
Map<String, Object> getVariables() {
|
|
||||||
return myVariables;
|
return myVariables;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public interface VimExtension {
|
public interface VimExtension {
|
||||||
@NotNull
|
@NotNull ExtensionPointName<ExtensionBeanClass> EP_NAME = ExtensionPointName.create("IdeaVIM.vimExtension");
|
||||||
ExtensionPointName<ExtensionBeanClass> EP_NAME = ExtensionPointName.create("IdeaVIM.vimExtension");
|
|
||||||
|
|
||||||
@VimNlsSafe
|
@VimNlsSafe
|
||||||
@NotNull
|
@NotNull String getName();
|
||||||
String getName();
|
|
||||||
|
|
||||||
default MappingOwner getOwner() {
|
default MappingOwner getOwner() {
|
||||||
return MappingOwner.Plugin.Companion.get(getName());
|
return MappingOwner.Plugin.Companion.get(getName());
|
||||||
|
@ -42,8 +42,7 @@ import static com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingI
|
|||||||
public class VimArgTextObjExtension implements VimExtension {
|
public class VimArgTextObjExtension implements VimExtension {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull
|
public @NotNull String getName() {
|
||||||
String getName() {
|
|
||||||
return "argtextobj";
|
return "argtextobj";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,10 +61,8 @@ public class VimArgTextObjExtension implements VimExtension {
|
|||||||
*/
|
*/
|
||||||
private static class BracketPairs {
|
private static class BracketPairs {
|
||||||
// NOTE: brackets must match by the position, and ordered by rank (highest to lowest).
|
// NOTE: brackets must match by the position, and ordered by rank (highest to lowest).
|
||||||
@NotNull
|
@NotNull private final String openBrackets;
|
||||||
private final String openBrackets;
|
@NotNull private final String closeBrackets;
|
||||||
@NotNull
|
|
||||||
private final String closeBrackets;
|
|
||||||
|
|
||||||
static class ParseException extends Exception {
|
static class ParseException extends Exception {
|
||||||
public ParseException(@NotNull String message) {
|
public ParseException(@NotNull String message) {
|
||||||
@ -213,8 +210,8 @@ public class VimArgTextObjExtension implements VimExtension {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ArgBoundsFinder finder = new ArgBoundsFinder(((IjVimEditor) editor).getEditor().getDocument(), bracketPairs);
|
final ArgBoundsFinder finder = new ArgBoundsFinder(((IjVimEditor)editor).getEditor().getDocument(), bracketPairs);
|
||||||
int pos = ((IjVimCaret) caret).getCaret().getOffset();
|
int pos = ((IjVimCaret)caret).getCaret().getOffset();
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
if (!finder.findBoundsAt(pos)) {
|
if (!finder.findBoundsAt(pos)) {
|
||||||
@ -261,14 +258,14 @@ public class VimArgTextObjExtension implements VimExtension {
|
|||||||
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
|
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
|
||||||
com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
|
com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
|
||||||
} else {
|
} else {
|
||||||
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret) caret).getCaret(), range.getStartOffset());
|
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret)caret).getCaret(), range.getStartOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||||
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
|
textObjectHandler, Command.Type.MOTION, EnumSet.noneOf(CommandFlags.class))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,18 +275,14 @@ public class VimArgTextObjExtension implements VimExtension {
|
|||||||
* position
|
* position
|
||||||
*/
|
*/
|
||||||
private static class ArgBoundsFinder {
|
private static class ArgBoundsFinder {
|
||||||
@NotNull
|
@NotNull private final CharSequence text;
|
||||||
private final CharSequence text;
|
@NotNull private final Document document;
|
||||||
@NotNull
|
@NotNull private final BracketPairs brackets;
|
||||||
private final Document document;
|
|
||||||
@NotNull
|
|
||||||
private final BracketPairs brackets;
|
|
||||||
private int leftBound = Integer.MAX_VALUE;
|
private int leftBound = Integer.MAX_VALUE;
|
||||||
private int rightBound = Integer.MIN_VALUE;
|
private int rightBound = Integer.MIN_VALUE;
|
||||||
private int leftBracket;
|
private int leftBracket;
|
||||||
private int rightBracket;
|
private int rightBracket;
|
||||||
private @Nls
|
private @Nls String error = null;
|
||||||
String error = null;
|
|
||||||
private static final String QUOTES = "\"'";
|
private static final String QUOTES = "\"'";
|
||||||
|
|
||||||
private static final int MAX_SEARCH_LINES = 10;
|
private static final int MAX_SEARCH_LINES = 10;
|
||||||
@ -419,7 +412,7 @@ public class VimArgTextObjExtension implements VimExtension {
|
|||||||
/**
|
/**
|
||||||
* Detects if current position is inside a quoted string and adjusts
|
* Detects if current position is inside a quoted string and adjusts
|
||||||
* left and right bounds to the boundaries of the string.
|
* left and right bounds to the boundaries of the string.
|
||||||
* <p>
|
*
|
||||||
* NOTE: Does not support line continuations for quoted string ('\' at the end of line).
|
* NOTE: Does not support line continuations for quoted string ('\' at the end of line).
|
||||||
*/
|
*/
|
||||||
private void getOutOfQuotedText() {
|
private void getOutOfQuotedText() {
|
||||||
|
@ -44,7 +44,7 @@ import static com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingI
|
|||||||
* <li>Then copy the resulting text to another application ("*yie)</li>
|
* <li>Then copy the resulting text to another application ("*yie)</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
*
|
||||||
* See also the reference manual for more details at:
|
* See also the reference manual for more details at:
|
||||||
* https://github.com/kana/vim-textobj-entire/blob/master/doc/textobj-entire.txt
|
* https://github.com/kana/vim-textobj-entire/blob/master/doc/textobj-entire.txt
|
||||||
*
|
*
|
||||||
@ -62,7 +62,7 @@ public class VimTextObjEntireExtension implements VimExtension {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-entire-a"), getOwner(),
|
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-entire-a"), getOwner(),
|
||||||
new VimTextObjEntireExtension.EntireHandler(false), false);
|
new VimTextObjEntireExtension.EntireHandler(false), false);
|
||||||
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-entire-i"), getOwner(),
|
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-entire-i"), getOwner(),
|
||||||
new VimTextObjEntireExtension.EntireHandler(true), false);
|
new VimTextObjEntireExtension.EntireHandler(true), false);
|
||||||
|
|
||||||
@ -97,12 +97,12 @@ public class VimTextObjEntireExtension implements VimExtension {
|
|||||||
int count,
|
int count,
|
||||||
int rawCount,
|
int rawCount,
|
||||||
@Nullable Argument argument) {
|
@Nullable Argument argument) {
|
||||||
int start = 0, end = ((IjVimEditor) editor).getEditor().getDocument().getTextLength();
|
int start = 0, end = ((IjVimEditor)editor).getEditor().getDocument().getTextLength();
|
||||||
|
|
||||||
// for the `ie` text object we don't want leading an trailing spaces
|
// for the `ie` text object we don't want leading an trailing spaces
|
||||||
// so we have to scan the document text to find the correct start & end
|
// so we have to scan the document text to find the correct start & end
|
||||||
if (ignoreLeadingAndTrailing) {
|
if (ignoreLeadingAndTrailing) {
|
||||||
String content = ((IjVimEditor) editor).getEditor().getDocument().getText();
|
String content = ((IjVimEditor)editor).getEditor().getDocument().getText();
|
||||||
for (int i = 0; i < content.length(); ++i) {
|
for (int i = 0; i < content.length(); ++i) {
|
||||||
if (!Character.isWhitespace(content.charAt(i))) {
|
if (!Character.isWhitespace(content.charAt(i))) {
|
||||||
start = i;
|
start = i;
|
||||||
@ -151,8 +151,8 @@ public class VimTextObjEntireExtension implements VimExtension {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||||
textObjectHandler, Command.Type.MOTION,
|
textObjectHandler, Command.Type.MOTION,
|
||||||
EnumSet.noneOf(CommandFlags.class))));
|
EnumSet.noneOf(CommandFlags.class))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import static com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMapping;
|
|||||||
* <li><code>aI</code> <b>A</b>n <b>I</b>ndentation level and lines above and below.</li>
|
* <li><code>aI</code> <b>A</b>n <b>I</b>ndentation level and lines above and below.</li>
|
||||||
* <li><code>iI</code> <b>I</b>nner <b>I</b>ndentation level (no lines above and below). Synonym of <code>ii</code></li>
|
* <li><code>iI</code> <b>I</b>nner <b>I</b>ndentation level (no lines above and below). Synonym of <code>ii</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
*
|
||||||
* See also the reference manual for more details at:
|
* See also the reference manual for more details at:
|
||||||
* https://github.com/michaeljsmith/vim-indent-object/blob/master/doc/indent-object.txt
|
* https://github.com/michaeljsmith/vim-indent-object/blob/master/doc/indent-object.txt
|
||||||
*
|
*
|
||||||
@ -58,7 +58,7 @@ public class VimIndentObject implements VimExtension {
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ai"), getOwner(),
|
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ai"), getOwner(),
|
||||||
new IndentObject(true, false), false);
|
new IndentObject(true, false), false);
|
||||||
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-aI"), getOwner(),
|
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-aI"), getOwner(),
|
||||||
new IndentObject(true, true), false);
|
new IndentObject(true, true), false);
|
||||||
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ii"), getOwner(),
|
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ii"), getOwner(),
|
||||||
@ -100,8 +100,8 @@ public class VimIndentObject implements VimExtension {
|
|||||||
int count,
|
int count,
|
||||||
int rawCount,
|
int rawCount,
|
||||||
@Nullable Argument argument) {
|
@Nullable Argument argument) {
|
||||||
final CharSequence charSequence = ((IjVimEditor) editor).getEditor().getDocument().getCharsSequence();
|
final CharSequence charSequence = ((IjVimEditor)editor).getEditor().getDocument().getCharsSequence();
|
||||||
final int caretOffset = ((IjVimCaret) caret).getCaret().getOffset();
|
final int caretOffset = ((IjVimCaret)caret).getCaret().getOffset();
|
||||||
|
|
||||||
// Part 1: Find the start of the caret line.
|
// Part 1: Find the start of the caret line.
|
||||||
int caretLineStartOffset = caretOffset;
|
int caretLineStartOffset = caretOffset;
|
||||||
@ -257,14 +257,14 @@ public class VimIndentObject implements VimExtension {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
|
public void execute(@NotNull VimEditor editor, @NotNull ExecutionContext context, @NotNull OperatorArguments operatorArguments) {
|
||||||
IjVimEditor vimEditor = (IjVimEditor) editor;
|
IjVimEditor vimEditor = (IjVimEditor)editor;
|
||||||
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
|
@NotNull VimStateMachine vimStateMachine = VimStateMachine.getInstance(vimEditor);
|
||||||
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
|
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
|
||||||
|
|
||||||
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
|
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
|
||||||
|
|
||||||
if (!vimStateMachine.isOperatorPending()) {
|
if (!vimStateMachine.isOperatorPending()) {
|
||||||
((IjVimEditor) editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
|
((IjVimEditor)editor).getEditor().getCaretModel().runForEachCaret((Caret caret) -> {
|
||||||
final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0, null);
|
final TextRange range = textObjectHandler.getRange(vimEditor, new IjVimCaret(caret), context, count, 0, null);
|
||||||
if (range != null) {
|
if (range != null) {
|
||||||
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
|
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
|
||||||
@ -279,8 +279,8 @@ public class VimIndentObject implements VimExtension {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
|
||||||
textObjectHandler, Command.Type.MOTION,
|
textObjectHandler, Command.Type.MOTION,
|
||||||
EnumSet.noneOf(CommandFlags.class))));
|
EnumSet.noneOf(CommandFlags.class))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
private long lastShownTime = 0L;
|
private long lastShownTime = 0L;
|
||||||
|
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull EditorMouseListener listener = new EditorMouseListener() {
|
||||||
EditorMouseListener listener = new EditorMouseListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(@NotNull EditorMouseEvent event) {
|
public void mouseClicked(@NotNull EditorMouseEvent event) {
|
||||||
Editor editor = event.getEditor();
|
Editor editor = event.getEditor();
|
||||||
@ -102,20 +101,20 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
DataContext ijContext = IjEditorExecutionContextKt.getIj(context);
|
DataContext ijContext = IjEditorExecutionContextKt.getIj(context);
|
||||||
final Document doc = ((IjVimEditor) vimEditor).getEditor().getDocument();
|
final Document doc = ((IjVimEditor) vimEditor).getEditor().getDocument();
|
||||||
CommandProcessor.getInstance().executeCommand(editor.getProject(), () -> ApplicationManager.getApplication()
|
CommandProcessor.getInstance().executeCommand(editor.getProject(), () -> ApplicationManager.getApplication()
|
||||||
.runWriteAction(() -> KeyHandlerKeeper.getInstance().getOriginalHandler().execute(editor, key, ijContext)), "", doc,
|
.runWriteAction(() -> KeyHandlerKeeper.getInstance().getOriginalHandler().execute(editor, key, ijContext)), "", doc,
|
||||||
UndoConfirmationPolicy.DEFAULT, doc);
|
UndoConfirmationPolicy.DEFAULT, doc);
|
||||||
injector.getScroll().scrollCaretIntoView(vimEditor);
|
injector.getScroll().scrollCaretIntoView(vimEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable
|
public @Nullable Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
|
||||||
Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
|
@NotNull VimCaret caret,
|
||||||
@NotNull VimCaret caret,
|
@NotNull ExecutionContext context,
|
||||||
@NotNull ExecutionContext context,
|
final @NotNull Argument argument,
|
||||||
final @NotNull Argument argument,
|
boolean isChange,
|
||||||
boolean isChange,
|
@NotNull OperatorArguments operatorArguments) {
|
||||||
@NotNull OperatorArguments operatorArguments) {
|
|
||||||
final TextRange range = MotionGroup.getMotionRange2(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), ((IjEditorExecutionContext) context).getContext(), argument, operatorArguments);
|
final TextRange range = MotionGroup.getMotionRange2(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), ((IjEditorExecutionContext) context).getContext(), argument, operatorArguments);
|
||||||
if (range == null) return null;
|
if (range == null) return null;
|
||||||
|
|
||||||
@ -126,7 +125,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
SelectionType type;
|
SelectionType type;
|
||||||
if (argument.getMotion().isLinewiseMotion()) {
|
if (argument.getMotion().isLinewiseMotion()) {
|
||||||
type = SelectionType.LINE_WISE;
|
type = SelectionType.LINE_WISE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
type = SelectionType.CHARACTER_WISE;
|
type = SelectionType.CHARACTER_WISE;
|
||||||
}
|
}
|
||||||
final Command motion = argument.getMotion();
|
final Command motion = argument.getMotion();
|
||||||
@ -161,11 +161,11 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
Motion motion = injector.getMotion().getHorizontalMotion(editor, caret, count, true, allowWrap);
|
Motion motion = injector.getMotion().getHorizontalMotion(editor, caret, count, true, allowWrap);
|
||||||
if (motion instanceof Motion.Error) return false;
|
if (motion instanceof Motion.Error) return false;
|
||||||
|
|
||||||
changeCase(editor, caret, caret.getOffset().getPoint(), ((Motion.AbsoluteOffset) motion).getOffset(), CharacterHelper.CASE_TOGGLE);
|
changeCase(editor, caret, caret.getOffset().getPoint(), ((Motion.AbsoluteOffset)motion).getOffset(), CharacterHelper.CASE_TOGGLE);
|
||||||
|
|
||||||
motion = injector.getMotion().getHorizontalMotion(editor, caret, count, false, allowWrap); // same but without allow end because we can change till end, but can't move caret there
|
motion = injector.getMotion().getHorizontalMotion(editor, caret, count, false, allowWrap); // same but without allow end because we can change till end, but can't move caret there
|
||||||
if (motion instanceof Motion.AbsoluteOffset) {
|
if (motion instanceof Motion.AbsoluteOffset) {
|
||||||
caret.moveToOffset(EngineEditorHelperKt.normalizeOffset(editor, ((Motion.AbsoluteOffset) motion).getOffset(), false));
|
caret.moveToOffset(EngineEditorHelperKt.normalizeOffset(editor, ((Motion.AbsoluteOffset)motion).getOffset(), false));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,13 +180,14 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset());
|
final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset());
|
||||||
|
|
||||||
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
|
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
|
||||||
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
|
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
|
||||||
for (VimCaret caret : editor.carets()) {
|
for (VimCaret caret : editor.carets()) {
|
||||||
final int line = startPosition.getLine();
|
final int line = startPosition.getLine();
|
||||||
int column = startPosition.getColumn();
|
int column = startPosition.getColumn();
|
||||||
if (!visualBlockMode) {
|
if (!visualBlockMode) {
|
||||||
column = 0;
|
column = 0;
|
||||||
} else if (append) {
|
}
|
||||||
|
else if (append) {
|
||||||
column += range.getMaxLength();
|
column += range.getMaxLength();
|
||||||
if (caret.getVimLastColumn() == VimMotionGroupBase.LAST_COLUMN) {
|
if (caret.getVimLastColumn() == VimMotionGroupBase.LAST_COLUMN) {
|
||||||
column = VimMotionGroupBase.LAST_COLUMN;
|
column = VimMotionGroupBase.LAST_COLUMN;
|
||||||
@ -201,7 +202,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (visualBlockMode || !append) {
|
if (visualBlockMode || !append) {
|
||||||
InlayHelperKt.moveToInlayAwareLogicalPosition(((IjVimCaret) caret).getCaret(), new LogicalPosition(line, column));
|
InlayHelperKt.moveToInlayAwareLogicalPosition(((IjVimCaret)caret).getCaret(), new LogicalPosition(line, column));
|
||||||
}
|
}
|
||||||
if (visualBlockMode) {
|
if (visualBlockMode) {
|
||||||
setInsertRepeat(lines, column, append);
|
setInsertRepeat(lines, column, append);
|
||||||
@ -210,7 +211,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
|
|
||||||
if (visualBlockMode || !append) {
|
if (visualBlockMode || !append) {
|
||||||
insertBeforeCursor(editor, context);
|
insertBeforeCursor(editor, context);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
insertAfterCursor(editor, context);
|
insertAfterCursor(editor, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +288,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
@NotNull Argument argument,
|
@NotNull Argument argument,
|
||||||
@NotNull OperatorArguments operatorArguments) {
|
@NotNull OperatorArguments operatorArguments) {
|
||||||
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
|
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
|
||||||
operatorArguments);
|
operatorArguments);
|
||||||
return range != null && changeCaseRange(editor, caret, range, type);
|
return range != null && changeCaseRange(editor, caret, range, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +299,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
@NotNull Argument argument,
|
@NotNull Argument argument,
|
||||||
@NotNull OperatorArguments operatorArguments) {
|
@NotNull OperatorArguments operatorArguments) {
|
||||||
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
|
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
|
||||||
operatorArguments);
|
operatorArguments);
|
||||||
return range != null && reformatCodeRange(editor, caret, range);
|
return range != null && reformatCodeRange(editor, caret, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +342,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument, operatorArguments);
|
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument, operatorArguments);
|
||||||
if (range != null) {
|
if (range != null) {
|
||||||
autoIndentRange(editor, caret, context,
|
autoIndentRange(editor, caret, context,
|
||||||
new TextRange(range.getStartOffset(), EngineHelperKt.getEndOffsetInclusive(range)));
|
new TextRange(range.getStartOffset(), EngineHelperKt.getEndOffsetInclusive(range)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,7 +354,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
final int startOffset = EngineEditorHelperKt.getLineStartForOffset(editor, range.getStartOffset());
|
final int startOffset = EngineEditorHelperKt.getLineStartForOffset(editor, range.getStartOffset());
|
||||||
final int endOffset = EngineEditorHelperKt.getLineEndForOffset(editor, range.getEndOffset());
|
final int endOffset = EngineEditorHelperKt.getLineEndForOffset(editor, range.getEndOffset());
|
||||||
|
|
||||||
Editor ijEditor = ((IjVimEditor) editor).getEditor();
|
Editor ijEditor = ((IjVimEditor)editor).getEditor();
|
||||||
VisualModeHelperKt.vimSetSystemSelectionSilently(ijEditor.getSelectionModel(), startOffset, endOffset);
|
VisualModeHelperKt.vimSetSystemSelectionSilently(ijEditor.getSelectionModel(), startOffset, endOffset);
|
||||||
|
|
||||||
Project project = ijEditor.getProject();
|
Project project = ijEditor.getProject();
|
||||||
@ -367,7 +369,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
final int firstLine = editor.offsetToBufferPosition(Math.min(startOffset, endOffset)).getLine();
|
final int firstLine = editor.offsetToBufferPosition(Math.min(startOffset, endOffset)).getLine();
|
||||||
final int newOffset = injector.getMotion().moveCaretToLineStartSkipLeading(editor, firstLine);
|
final int newOffset = injector.getMotion().moveCaretToLineStartSkipLeading(editor, firstLine);
|
||||||
caret.moveToOffset(newOffset);
|
caret.moveToOffset(newOffset);
|
||||||
restoreCursor(editor, caret, ((IjVimCaret) caret).getCaret().getLogicalPosition().line);
|
restoreCursor(editor, caret, ((IjVimCaret)caret).getCaret().getLogicalPosition().line);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
@ -440,7 +442,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
insertText(editor, caret, spos, indent);
|
insertText(editor, caret, spos, indent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Left shift blockwise selection
|
// Left shift blockwise selection
|
||||||
CharSequence chars = editor.text();
|
CharSequence chars = editor.text();
|
||||||
for (int l = sline; l <= eline; l++) {
|
for (int l = sline; l <= eline; l++) {
|
||||||
@ -462,7 +465,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Shift non-blockwise selection
|
// Shift non-blockwise selection
|
||||||
for (int l = sline; l <= eline; l++) {
|
for (int l = sline; l <= eline; l++) {
|
||||||
final int soff = editor.getLineStartOffset(l);
|
final int soff = editor.getLineStartOffset(l);
|
||||||
@ -483,7 +487,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
VimCaret newCaret = caret.setVimLastColumnAndGetCaret(intendedColumn);
|
VimCaret newCaret = caret.setVimLastColumnAndGetCaret(intendedColumn);
|
||||||
final int offset = injector.getMotion().moveCaretToLineWithStartOfLineOption(editor, sline, caret);
|
final int offset = injector.getMotion().moveCaretToLineWithStartOfLineOption(editor, sline, caret);
|
||||||
newCaret.moveToOffset(offset);
|
newCaret.moveToOffset(offset);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
caret.moveToOffset(range.getStartOffset());
|
caret.moveToOffset(range.getStartOffset());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,10 +564,10 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
ApplicationManager.getApplication().invokeLater(() -> {
|
ApplicationManager.getApplication().invokeLater(() -> {
|
||||||
final Balloon balloon = JBPopupFactory.getInstance()
|
final Balloon balloon = JBPopupFactory.getInstance()
|
||||||
.createHtmlTextBalloonBuilder("Wow, nice vim skills!", VimIcons.IDEAVIM,
|
.createHtmlTextBalloonBuilder("Wow, nice vim skills!", VimIcons.IDEAVIM,
|
||||||
MessageType.INFO.getTitleForeground(), MessageType.INFO.getPopupBackground(),
|
MessageType.INFO.getTitleForeground(), MessageType.INFO.getPopupBackground(),
|
||||||
null).createBalloon();
|
null).createBalloon();
|
||||||
balloon.show(JBPopupFactory.getInstance().guessBestPopupLocation(((IjVimEditor) editor).getEditor()),
|
balloon.show(JBPopupFactory.getInstance().guessBestPopupLocation(((IjVimEditor)editor).getEditor()),
|
||||||
Balloon.Position.below);
|
Balloon.Position.below);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -612,7 +617,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
String newNumber = changeNumberInRange(editor, range, count, alpha, hex, octal);
|
String newNumber = changeNumberInRange(editor, range, count, alpha, hex, octal);
|
||||||
if (newNumber == null) {
|
if (newNumber == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
replaceText(editor, caret, range.getFirst().getStartOffset(), range.getFirst().getEndOffset(), newNumber);
|
replaceText(editor, caret, range.getFirst().getStartOffset(), range.getFirst().getEndOffset(), newNumber);
|
||||||
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret) caret).getCaret(), range.getFirst().getStartOffset() + newNumber.length() - 1);
|
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret) caret).getCaret(), range.getFirst().getStartOffset() + newNumber.length() - 1);
|
||||||
return true;
|
return true;
|
||||||
@ -634,13 +640,12 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
strokes.add(chars);
|
strokes.add(chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable String changeNumberInRange(final @NotNull VimEditor editor,
|
||||||
String changeNumberInRange(final @NotNull VimEditor editor,
|
Pair<TextRange, NumberType> range,
|
||||||
Pair<TextRange, NumberType> range,
|
final int count,
|
||||||
final int count,
|
boolean alpha,
|
||||||
boolean alpha,
|
boolean hex,
|
||||||
boolean hex,
|
boolean octal) {
|
||||||
boolean octal) {
|
|
||||||
String text = EngineEditorHelperKt.getText(editor, range.getFirst());
|
String text = EngineEditorHelperKt.getText(editor, range.getFirst());
|
||||||
NumberType numberType = range.getSecond();
|
NumberType numberType = range.getSecond();
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
@ -678,7 +683,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
number = text.substring(0, 2) + number;
|
number = text.substring(0, 2) + number;
|
||||||
} else if (octal && NumberType.OCT.equals(numberType) && text.length() > 1) {
|
}
|
||||||
|
else if (octal && NumberType.OCT.equals(numberType) && text.length() > 1) {
|
||||||
if (!text.startsWith("0")) throw new RuntimeException("Oct number should start with 0: " + text);
|
if (!text.startsWith("0")) throw new RuntimeException("Oct number should start with 0: " + text);
|
||||||
BigInteger num = new BigInteger(text, 8).add(BigInteger.valueOf(count));
|
BigInteger num = new BigInteger(text, 8).add(BigInteger.valueOf(count));
|
||||||
|
|
||||||
@ -687,13 +693,15 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
}
|
}
|
||||||
number = num.toString(8);
|
number = num.toString(8);
|
||||||
number = "0" + StringsKt.padStart(number, text.length() - 1, '0');
|
number = "0" + StringsKt.padStart(number, text.length() - 1, '0');
|
||||||
} else if (alpha && NumberType.ALPHA.equals(numberType)) {
|
}
|
||||||
|
else if (alpha && NumberType.ALPHA.equals(numberType)) {
|
||||||
if (!Character.isLetter(ch)) throw new RuntimeException("Not alpha number : " + text);
|
if (!Character.isLetter(ch)) throw new RuntimeException("Not alpha number : " + text);
|
||||||
ch += count;
|
ch += count;
|
||||||
if (Character.isLetter(ch)) {
|
if (Character.isLetter(ch)) {
|
||||||
number = String.valueOf(ch);
|
number = String.valueOf(ch);
|
||||||
}
|
}
|
||||||
} else if (NumberType.DEC.equals(numberType)) {
|
}
|
||||||
|
else if (NumberType.DEC.equals(numberType)) {
|
||||||
if (ch != '-' && !Character.isDigit(ch)) throw new RuntimeException("Not dec number : " + text);
|
if (ch != '-' && !Character.isDigit(ch)) throw new RuntimeException("Not dec number : " + text);
|
||||||
boolean pad = ch == '0';
|
boolean pad = ch == '0';
|
||||||
int len = text.length();
|
int len = text.length();
|
||||||
@ -732,7 +740,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyListeners(@NotNull VimEditor editor) {
|
public void notifyListeners(@NotNull VimEditor editor) {
|
||||||
insertListeners.forEach(listener -> listener.insertModeStarted(((IjVimEditor) editor).getEditor()));
|
insertListeners.forEach(listener -> listener.insertModeStarted(((IjVimEditor)editor).getEditor()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -742,5 +750,6 @@ public class ChangeGroup extends VimChangeGroupBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getInstance(ChangeGroup.class.getName());
|
private static final Logger logger = Logger.getInstance(ChangeGroup.class.getName());
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class DigraphGroup extends VimDigraphGroupBase {
|
|||||||
width = 80;
|
width = 80;
|
||||||
}
|
}
|
||||||
int colCount = width / 12;
|
int colCount = width / 12;
|
||||||
int height = (int) Math.ceil((double) getDigraphs().size() / (double) colCount);
|
int height = (int)Math.ceil((double) getDigraphs().size() / (double)colCount);
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("width=" + width);
|
logger.debug("width=" + width);
|
||||||
@ -41,11 +41,13 @@ public class DigraphGroup extends VimDigraphGroupBase {
|
|||||||
res.append(' ');
|
res.append(' ');
|
||||||
if (code < 32) {
|
if (code < 32) {
|
||||||
res.append('^');
|
res.append('^');
|
||||||
res.append((char) (code + '@'));
|
res.append((char)(code + '@'));
|
||||||
} else if (code >= 128 && code <= 159) {
|
}
|
||||||
|
else if (code >= 128 && code <= 159) {
|
||||||
res.append('~');
|
res.append('~');
|
||||||
res.append((char) (code - 128 + '@'));
|
res.append((char)(code - 128 + '@'));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
res.append(code);
|
res.append(code);
|
||||||
res.append(' ');
|
res.append(' ');
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ import static com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.update
|
|||||||
*/
|
*/
|
||||||
@State(name = "VimEditorSettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
|
@State(name = "VimEditorSettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
|
||||||
public class EditorGroup implements PersistentStateComponent<Element>, VimEditorGroup {
|
public class EditorGroup implements PersistentStateComponent<Element>, VimEditorGroup {
|
||||||
public static final @NonNls
|
public static final @NonNls String EDITOR_STORE_ELEMENT = "editor";
|
||||||
String EDITOR_STORE_ELEMENT = "editor";
|
|
||||||
|
|
||||||
private Boolean isKeyRepeat = null;
|
private Boolean isKeyRepeat = null;
|
||||||
|
|
||||||
@ -126,7 +125,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
|
|||||||
if (!hasRelativeLineNumbersInstalled(editor)) {
|
if (!hasRelativeLineNumbersInstalled(editor)) {
|
||||||
installRelativeLineNumbers(editor);
|
installRelativeLineNumbers(editor);
|
||||||
}
|
}
|
||||||
} else if (hasRelativeLineNumbersInstalled(editor)) {
|
}
|
||||||
|
else if (hasRelativeLineNumbersInstalled(editor)) {
|
||||||
removeRelativeLineNumbers(editor);
|
removeRelativeLineNumbers(editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,8 +192,7 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
public @Nullable Boolean isKeyRepeat() {
|
||||||
Boolean isKeyRepeat() {
|
|
||||||
return isKeyRepeat;
|
return isKeyRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,8 +214,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
|
|||||||
initLineNumbers(editor);
|
initLineNumbers(editor);
|
||||||
// Turn on insert mode if editor doesn't have any file
|
// Turn on insert mode if editor doesn't have any file
|
||||||
if (!EditorHelper.isFileEditor(editor) &&
|
if (!EditorHelper.isFileEditor(editor) &&
|
||||||
editor.getDocument().isWritable() &&
|
editor.getDocument().isWritable() &&
|
||||||
!CommandStateHelper.inInsertMode(editor)) {
|
!CommandStateHelper.inInsertMode(editor)) {
|
||||||
ExecutionContext.Editor context = injector.getExecutionContextManager().onEditor(new IjVimEditor(editor), null);
|
ExecutionContext.Editor context = injector.getExecutionContextManager().onEditor(new IjVimEditor(editor), null);
|
||||||
VimPlugin.getChange().insertBeforeCursor(new IjVimEditor(editor), context);
|
VimPlugin.getChange().insertBeforeCursor(new IjVimEditor(editor), context);
|
||||||
KeyHandler.getInstance().reset(new IjVimEditor(editor));
|
KeyHandler.getInstance().reset(new IjVimEditor(editor));
|
||||||
@ -277,7 +276,7 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processLocalValueChange(@Nullable VimDataType oldValue, @NotNull VimEditor editor) {
|
public void processLocalValueChange(@Nullable VimDataType oldValue, @NotNull VimEditor editor) {
|
||||||
Editor ijEditor = ((IjVimEditor) editor).getEditor();
|
Editor ijEditor = ((IjVimEditor)editor).getEditor();
|
||||||
|
|
||||||
if (UserDataManager.getVimEditorGroup(ijEditor) && supportsVimLineNumbers(ijEditor)) {
|
if (UserDataManager.getVimEditorGroup(ijEditor) && supportsVimLineNumbers(ijEditor)) {
|
||||||
updateLineNumbers(ijEditor);
|
updateLineNumbers(ijEditor);
|
||||||
@ -294,7 +293,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
|
|||||||
// lineNumber is 1 based
|
// lineNumber is 1 based
|
||||||
if (number && (lineNumber - 1) == caretLine) {
|
if (number && (lineNumber - 1) == caretLine) {
|
||||||
return lineNumber;
|
return lineNumber;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final int visualLine = new IjVimEditor(editor).bufferLineToVisualLine(lineNumber - 1);
|
final int visualLine = new IjVimEditor(editor).bufferLineToVisualLine(lineNumber - 1);
|
||||||
final int currentVisualLine = new IjVimEditor(editor).bufferLineToVisualLine(caretLine);
|
final int currentVisualLine = new IjVimEditor(editor).bufferLineToVisualLine(caretLine);
|
||||||
return Math.abs(currentVisualLine - visualLine);
|
return Math.abs(currentVisualLine - visualLine);
|
||||||
|
@ -72,20 +72,21 @@ public class FileGroup extends VimFileBase {
|
|||||||
fem.openFile(found, true);
|
fem.openFile(found, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// There was no type and user didn't pick one. Don't open the file
|
// There was no type and user didn't pick one. Don't open the file
|
||||||
// Return true here because we found the file but the user canceled by not picking a type.
|
// Return true here because we found the file but the user canceled by not picking a type.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
VimPlugin.showMessage(MessageHelper.message("unable.to.find.0", filename));
|
VimPlugin.showMessage(MessageHelper.message("unable.to.find.0", filename));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable VirtualFile findFile(@NotNull String filename, @NotNull Project project) {
|
||||||
VirtualFile findFile(@NotNull String filename, @NotNull Project project) {
|
|
||||||
VirtualFile found;
|
VirtualFile found;
|
||||||
if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
|
if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
|
||||||
String homefile = filename.substring(2);
|
String homefile = filename.substring(2);
|
||||||
@ -95,7 +96,8 @@ public class FileGroup extends VimFileBase {
|
|||||||
logger.debug("looking for " + homefile + " in " + dir);
|
logger.debug("looking for " + homefile + " in " + dir);
|
||||||
}
|
}
|
||||||
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
|
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
|
found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
|
||||||
|
|
||||||
if (found == null) {
|
if (found == null) {
|
||||||
@ -141,11 +143,11 @@ public class FileGroup extends VimFileBase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void closeFile(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
|
public void closeFile(@NotNull VimEditor editor, @NotNull ExecutionContext context) {
|
||||||
final Project project = PlatformDataKeys.PROJECT.getData(((DataContext) context.getContext()));
|
final Project project = PlatformDataKeys.PROJECT.getData(((DataContext)context.getContext()));
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
|
||||||
final EditorWindow window = fileEditorManager.getCurrentWindow();
|
final EditorWindow window = fileEditorManager.getCurrentWindow();
|
||||||
final VirtualFile virtualFile = EditorHelper.getVirtualFile(((IjVimEditor) editor).getEditor());
|
final VirtualFile virtualFile = EditorHelper.getVirtualFile(((IjVimEditor)editor).getEditor());
|
||||||
|
|
||||||
if (virtualFile != null && window != null) {
|
if (virtualFile != null && window != null) {
|
||||||
window.closeFile(virtualFile);
|
window.closeFile(virtualFile);
|
||||||
@ -171,8 +173,7 @@ public class FileGroup extends VimFileBase {
|
|||||||
if (number >= 0 && number < editors.length) {
|
if (number >= 0 && number < editors.length) {
|
||||||
fileEditorManager.closeFile(editors[number], window);
|
fileEditorManager.closeFile(editors[number], window);
|
||||||
}
|
}
|
||||||
}
|
} if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
|
||||||
// This thing doesn't have an implementation in test mode
|
// This thing doesn't have an implementation in test mode
|
||||||
EditorsSplitters.focusDefaultComponentInSplittersIfPresent(project);
|
EditorsSplitters.focusDefaultComponentInSplittersIfPresent(project);
|
||||||
}
|
}
|
||||||
@ -186,7 +187,8 @@ public class FileGroup extends VimFileBase {
|
|||||||
NativeAction action;
|
NativeAction action;
|
||||||
if (globalOptions(injector).hasValue(IjOptionConstants.ideawrite, IjOptionConstants.ideawrite_all)) {
|
if (globalOptions(injector).hasValue(IjOptionConstants.ideawrite, IjOptionConstants.ideawrite_all)) {
|
||||||
action = injector.getNativeActionManager().getSaveAll();
|
action = injector.getNativeActionManager().getSaveAll();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
action = injector.getNativeActionManager().getSaveCurrent();
|
action = injector.getNativeActionManager().getSaveCurrent();
|
||||||
}
|
}
|
||||||
ExecuteExtensionKt.execute(action, context);
|
ExecuteExtensionKt.execute(action, context);
|
||||||
@ -243,12 +245,13 @@ public class FileGroup extends VimFileBase {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void selectPreviousTab(@NotNull ExecutionContext context) {
|
public void selectPreviousTab(@NotNull ExecutionContext context) {
|
||||||
Project project = PlatformDataKeys.PROJECT.getData(((DataContext) context.getContext()));
|
Project project = PlatformDataKeys.PROJECT.getData(((DataContext)context.getContext()));
|
||||||
if (project == null) return;
|
if (project == null) return;
|
||||||
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
|
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
|
||||||
if (vf != null && vf.isValid()) {
|
if (vf != null && vf.isValid()) {
|
||||||
FileEditorManager.getInstance(project).openFile(vf, true);
|
FileEditorManager.getInstance(project).openFile(vf, true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
VimPlugin.indicateError();
|
VimPlugin.indicateError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,8 +259,7 @@ public class FileGroup extends VimFileBase {
|
|||||||
/**
|
/**
|
||||||
* Returns the previous tab.
|
* Returns the previous tab.
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable VirtualFile getPreviousTab(@NotNull DataContext context) {
|
||||||
VirtualFile getPreviousTab(@NotNull DataContext context) {
|
|
||||||
Project project = PlatformDataKeys.PROJECT.getData(context);
|
Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||||
if (project == null) return null;
|
if (project == null) return null;
|
||||||
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
|
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
|
||||||
@ -267,13 +269,12 @@ public class FileGroup extends VimFileBase {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable Editor selectEditor(Project project, @NotNull VirtualFile file) {
|
||||||
Editor selectEditor(Project project, @NotNull VirtualFile file) {
|
|
||||||
FileEditorManager fMgr = FileEditorManager.getInstance(project);
|
FileEditorManager fMgr = FileEditorManager.getInstance(project);
|
||||||
FileEditor[] feditors = fMgr.openFile(file, true);
|
FileEditor[] feditors = fMgr.openFile(file, true);
|
||||||
if (feditors.length > 0) {
|
if (feditors.length > 0) {
|
||||||
if (feditors[0] instanceof TextEditor) {
|
if (feditors[0] instanceof TextEditor) {
|
||||||
Editor editor = ((TextEditor) feditors[0]).getEditor();
|
Editor editor = ((TextEditor)feditors[0]).getEditor();
|
||||||
if (!editor.isDisposed()) {
|
if (!editor.isDisposed()) {
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
@ -285,7 +286,7 @@ public class FileGroup extends VimFileBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayLocationInfo(@NotNull VimEditor vimEditor) {
|
public void displayLocationInfo(@NotNull VimEditor vimEditor) {
|
||||||
Editor editor = ((IjVimEditor) vimEditor).getEditor();
|
Editor editor = ((IjVimEditor)vimEditor).getEditor();
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
Document doc = editor.getDocument();
|
Document doc = editor.getDocument();
|
||||||
|
|
||||||
@ -322,11 +323,12 @@ public class FileGroup extends VimFileBase {
|
|||||||
int size = EditorHelperRt.getFileSize(editor);
|
int size = EditorHelperRt.getFileSize(editor);
|
||||||
|
|
||||||
msg.append("; Character ").append(offset + 1).append(" of ").append(size);
|
msg.append("; Character ").append(offset + 1).append(" of ").append(size);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
msg.append("Selected ");
|
msg.append("Selected ");
|
||||||
|
|
||||||
TextRange vr = new TextRange(editor.getSelectionModel().getBlockSelectionStarts(),
|
TextRange vr = new TextRange(editor.getSelectionModel().getBlockSelectionStarts(),
|
||||||
editor.getSelectionModel().getBlockSelectionEnds());
|
editor.getSelectionModel().getBlockSelectionEnds());
|
||||||
vr.normalize();
|
vr.normalize();
|
||||||
|
|
||||||
int lines;
|
int lines;
|
||||||
@ -343,7 +345,8 @@ public class FileGroup extends VimFileBase {
|
|||||||
cp = SearchHelper.countWords(editor, vr.getStartOffsets()[i], vr.getEndOffsets()[i] - 1);
|
cp = SearchHelper.countWords(editor, vr.getStartOffsets()[i], vr.getEndOffsets()[i] - 1);
|
||||||
word += cp.getCount();
|
word += cp.getCount();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
LogicalPosition slp = editor.offsetToLogicalPosition(vr.getStartOffset());
|
LogicalPosition slp = editor.offsetToLogicalPosition(vr.getStartOffset());
|
||||||
LogicalPosition elp = editor.offsetToLogicalPosition(vr.getEndOffset());
|
LogicalPosition elp = editor.offsetToLogicalPosition(vr.getEndOffset());
|
||||||
|
|
||||||
@ -370,39 +373,43 @@ public class FileGroup extends VimFileBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayFileInfo(@NotNull VimEditor vimEditor, boolean fullPath) {
|
public void displayFileInfo(@NotNull VimEditor vimEditor, boolean fullPath) {
|
||||||
Editor editor = ((IjVimEditor) vimEditor).getEditor();
|
Editor editor = ((IjVimEditor)vimEditor).getEditor();
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
VirtualFile vf = EditorHelper.getVirtualFile(editor);
|
VirtualFile vf = EditorHelper.getVirtualFile(editor);
|
||||||
if (vf != null) {
|
if (vf != null) {
|
||||||
msg.append('"');
|
msg.append('"');
|
||||||
if (fullPath) {
|
if (fullPath) {
|
||||||
msg.append(vf.getPath());
|
msg.append(vf.getPath());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Project project = editor.getProject();
|
Project project = editor.getProject();
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
VirtualFile root = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(vf);
|
VirtualFile root = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(vf);
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
msg.append(vf.getPath().substring(root.getPath().length() + 1));
|
msg.append(vf.getPath().substring(root.getPath().length() + 1));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
msg.append(vf.getPath());
|
msg.append(vf.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.append("\" ");
|
msg.append("\" ");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
msg.append("\"[No File]\" ");
|
msg.append("\"[No File]\" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Document doc = editor.getDocument();
|
Document doc = editor.getDocument();
|
||||||
if (!doc.isWritable()) {
|
if (!doc.isWritable()) {
|
||||||
msg.append("[RO] ");
|
msg.append("[RO] ");
|
||||||
} else if (FileDocumentManager.getInstance().isDocumentUnsaved(doc)) {
|
}
|
||||||
|
else if (FileDocumentManager.getInstance().isDocumentUnsaved(doc)) {
|
||||||
msg.append("[+] ");
|
msg.append("[+] ");
|
||||||
}
|
}
|
||||||
|
|
||||||
int lline = editor.getCaretModel().getLogicalPosition().line;
|
int lline = editor.getCaretModel().getLogicalPosition().line;
|
||||||
int total = new IjVimEditor(editor).lineCount();
|
int total = new IjVimEditor(editor).lineCount();
|
||||||
int pct = (int) ((float) lline / (float) total * 100f + 0.5);
|
int pct = (int)((float)lline / (float)total * 100f + 0.5);
|
||||||
|
|
||||||
msg.append("line ").append(lline + 1).append(" of ").append(total);
|
msg.append("line ").append(lline + 1).append(" of ").append(total);
|
||||||
msg.append(" --").append(pct).append("%-- ");
|
msg.append(" --").append(pct).append("%-- ");
|
||||||
@ -418,8 +425,7 @@ public class FileGroup extends VimFileBase {
|
|||||||
VimPlugin.showMessage(msg.toString());
|
VimPlugin.showMessage(msg.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final @NotNull
|
private static final @NotNull Logger logger = Logger.getInstance(FileGroup.class.getName());
|
||||||
Logger logger = Logger.getInstance(FileGroup.class.getName());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method listens for editor tab changes so any insert/replace modes that need to be reset can be.
|
* This method listens for editor tab changes so any insert/replace modes that need to be reset can be.
|
||||||
|
@ -55,13 +55,10 @@ import static java.util.stream.Collectors.toList;
|
|||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
@State(name = "VimKeySettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
|
@State(name = "VimKeySettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
|
||||||
public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponent<Element> {
|
public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponent<Element>{
|
||||||
public static final @NonNls
|
public static final @NonNls String SHORTCUT_CONFLICTS_ELEMENT = "shortcut-conflicts";
|
||||||
String SHORTCUT_CONFLICTS_ELEMENT = "shortcut-conflicts";
|
private static final @NonNls String SHORTCUT_CONFLICT_ELEMENT = "shortcut-conflict";
|
||||||
private static final @NonNls
|
private static final @NonNls String OWNER_ATTRIBUTE = "owner";
|
||||||
String SHORTCUT_CONFLICT_ELEMENT = "shortcut-conflict";
|
|
||||||
private static final @NonNls
|
|
||||||
String OWNER_ATTRIBUTE = "owner";
|
|
||||||
private static final String TEXT_ELEMENT = "text";
|
private static final String TEXT_ELEMENT = "text";
|
||||||
|
|
||||||
private static final Logger logger = Logger.getInstance(KeyGroup.class);
|
private static final Logger logger = Logger.getInstance(KeyGroup.class);
|
||||||
@ -69,18 +66,18 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
public void registerRequiredShortcutKeys(@NotNull VimEditor editor) {
|
public void registerRequiredShortcutKeys(@NotNull VimEditor editor) {
|
||||||
EventFacade.getInstance()
|
EventFacade.getInstance()
|
||||||
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
|
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
|
||||||
((IjVimEditor) editor).getEditor().getComponent());
|
((IjVimEditor)editor).getEditor().getComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerShortcutsForLookup(@NotNull LookupImpl lookup) {
|
public void registerShortcutsForLookup(@NotNull LookupImpl lookup) {
|
||||||
EventFacade.getInstance()
|
EventFacade.getInstance()
|
||||||
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
|
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
|
||||||
lookup.getComponent(), lookup);
|
lookup.getComponent(), lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregisterShortcutKeys(@NotNull VimEditor editor) {
|
void unregisterShortcutKeys(@NotNull VimEditor editor) {
|
||||||
EventFacade.getInstance().unregisterCustomShortcutSet(VimShortcutKeyAction.getInstance(),
|
EventFacade.getInstance().unregisterCustomShortcutSet(VimShortcutKeyAction.getInstance(),
|
||||||
((IjVimEditor) editor).getEditor().getComponent());
|
((IjVimEditor)editor).getEditor().getComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showKeyMappings(@NotNull Set<? extends MappingMode> modes, @NotNull Editor editor) {
|
public boolean showKeyMappings(@NotNull Set<? extends MappingMode> modes, @NotNull Editor editor) {
|
||||||
@ -116,10 +113,12 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
final ShortcutOwner owner;
|
final ShortcutOwner owner;
|
||||||
ShortcutOwnerInfo myValue = entry.getValue();
|
ShortcutOwnerInfo myValue = entry.getValue();
|
||||||
if (myValue instanceof ShortcutOwnerInfo.AllModes) {
|
if (myValue instanceof ShortcutOwnerInfo.AllModes) {
|
||||||
owner = ((ShortcutOwnerInfo.AllModes) myValue).getOwner();
|
owner = ((ShortcutOwnerInfo.AllModes)myValue).getOwner();
|
||||||
} else if (myValue instanceof ShortcutOwnerInfo.PerMode) {
|
}
|
||||||
|
else if (myValue instanceof ShortcutOwnerInfo.PerMode) {
|
||||||
owner = null;
|
owner = null;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
if (owner != null && owner != ShortcutOwner.UNDEFINED) {
|
if (owner != null && owner != ShortcutOwner.UNDEFINED) {
|
||||||
@ -143,7 +142,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
ShortcutOwner owner = ShortcutOwner.UNDEFINED;
|
ShortcutOwner owner = ShortcutOwner.UNDEFINED;
|
||||||
try {
|
try {
|
||||||
owner = ShortcutOwner.fromString(ownerValue);
|
owner = ShortcutOwner.fromString(ownerValue);
|
||||||
} catch (IllegalArgumentException ignored) {
|
}
|
||||||
|
catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
final Element textElement = conflictElement.getChild(TEXT_ELEMENT);
|
final Element textElement = conflictElement.getChild(TEXT_ELEMENT);
|
||||||
if (textElement != null) {
|
if (textElement != null) {
|
||||||
@ -160,8 +160,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull
|
public @NotNull List<NativeAction> getKeymapConflicts(@NotNull KeyStroke keyStroke) {
|
||||||
List<NativeAction> getKeymapConflicts(@NotNull KeyStroke keyStroke) {
|
|
||||||
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
|
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
|
||||||
final Keymap keymap = keymapManager.getActiveKeymap();
|
final Keymap keymap = keymapManager.getActiveKeymap();
|
||||||
final KeyboardShortcut shortcut = new KeyboardShortcut(keyStroke, null);
|
final KeyboardShortcut shortcut = new KeyboardShortcut(keyStroke, null);
|
||||||
@ -176,8 +175,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
return actions.stream().map(IjNativeAction::new).collect(toList());
|
return actions.stream().map(IjNativeAction::new).collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull
|
public @NotNull Map<KeyStroke, ShortcutOwnerInfo> getShortcutConflicts() {
|
||||||
Map<KeyStroke, ShortcutOwnerInfo> getShortcutConflicts() {
|
|
||||||
final Set<RequiredShortcut> requiredShortcutKeys = this.getRequiredShortcutKeys();
|
final Set<RequiredShortcut> requiredShortcutKeys = this.getRequiredShortcutKeys();
|
||||||
final Map<KeyStroke, ShortcutOwnerInfo> savedConflicts = getSavedShortcutConflicts();
|
final Map<KeyStroke, ShortcutOwnerInfo> savedConflicts = getSavedShortcutConflicts();
|
||||||
final Map<KeyStroke, ShortcutOwnerInfo> results = new HashMap<>();
|
final Map<KeyStroke, ShortcutOwnerInfo> results = new HashMap<>();
|
||||||
@ -212,13 +210,13 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommandAction(@NotNull VimActionsInitiator actionHolder) {
|
public void registerCommandAction(@NotNull VimActionsInitiator actionHolder) {
|
||||||
IjVimActionsInitiator holder = (IjVimActionsInitiator) actionHolder;
|
IjVimActionsInitiator holder = (IjVimActionsInitiator)actionHolder;
|
||||||
|
|
||||||
if (!VimPlugin.getPluginId().equals(holder.getBean().getPluginDescriptor().getPluginId())) {
|
if (!VimPlugin.getPluginId().equals(holder.getBean().getPluginDescriptor().getPluginId())) {
|
||||||
logger.error("IdeaVim doesn't accept contributions to `vimActions` extension points. " +
|
logger.error("IdeaVim doesn't accept contributions to `vimActions` extension points. " +
|
||||||
"Please create a plugin using `VimExtension`. " +
|
"Please create a plugin using `VimExtension`. " +
|
||||||
"Plugin to blame: " +
|
"Plugin to blame: " +
|
||||||
holder.getBean().getPluginDescriptor().getPluginId());
|
holder.getBean().getPluginDescriptor().getPluginId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,8 +224,9 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
if (actionKeys == null) {
|
if (actionKeys == null) {
|
||||||
final EditorActionHandlerBase action = actionHolder.getInstance();
|
final EditorActionHandlerBase action = actionHolder.getInstance();
|
||||||
if (action instanceof ComplicatedKeysAction) {
|
if (action instanceof ComplicatedKeysAction) {
|
||||||
actionKeys = ((ComplicatedKeysAction) action).getKeyStrokesSet();
|
actionKeys = ((ComplicatedKeysAction)action).getKeyStrokesSet();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
throw new RuntimeException("Cannot register action: " + action.getClass().getName());
|
throw new RuntimeException("Cannot register action: " + action.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -262,8 +261,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull ShortcutSet toShortcutSet(@NotNull Collection<RequiredShortcut> requiredShortcuts) {
|
||||||
ShortcutSet toShortcutSet(@NotNull Collection<RequiredShortcut> requiredShortcuts) {
|
|
||||||
final List<Shortcut> shortcuts = new ArrayList<>();
|
final List<Shortcut> shortcuts = new ArrayList<>();
|
||||||
for (RequiredShortcut key : requiredShortcuts) {
|
for (RequiredShortcut key : requiredShortcuts) {
|
||||||
shortcuts.add(new KeyboardShortcut(key.getKeyStroke(), null));
|
shortcuts.add(new KeyboardShortcut(key.getKeyStroke(), null));
|
||||||
@ -271,8 +269,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
return new CustomShortcutSet(shortcuts.toArray(new Shortcut[0]));
|
return new CustomShortcutSet(shortcuts.toArray(new Shortcut[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull List<Pair<EnumSet<MappingMode>, MappingInfo>> getKeyMappingRows(@NotNull Set<? extends MappingMode> modes) {
|
||||||
List<Pair<EnumSet<MappingMode>, MappingInfo>> getKeyMappingRows(@NotNull Set<? extends MappingMode> modes) {
|
|
||||||
final Map<ImmutableList<KeyStroke>, EnumSet<MappingMode>> actualModes = new HashMap<>();
|
final Map<ImmutableList<KeyStroke>, EnumSet<MappingMode>> actualModes = new HashMap<>();
|
||||||
for (MappingMode mode : modes) {
|
for (MappingMode mode : modes) {
|
||||||
final KeyMapping mapping = VimPlugin.getKey().getKeyMapping(mode);
|
final KeyMapping mapping = VimPlugin.getKey().getKeyMapping(mode);
|
||||||
@ -283,7 +280,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
newValue = value.clone();
|
newValue = value.clone();
|
||||||
newValue.add(mode);
|
newValue.add(mode);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
newValue = EnumSet.of(mode);
|
newValue = EnumSet.of(mode);
|
||||||
}
|
}
|
||||||
actualModes.put(key, newValue);
|
actualModes.put(key, newValue);
|
||||||
@ -306,22 +304,21 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull @NonNls String getModesStringCode(@NotNull Set<MappingMode> modes) {
|
||||||
@NonNls
|
|
||||||
String getModesStringCode(@NotNull Set<MappingMode> modes) {
|
|
||||||
if (modes.equals(MappingMode.NVO)) {
|
if (modes.equals(MappingMode.NVO)) {
|
||||||
return "";
|
return "";
|
||||||
} else if (modes.contains(MappingMode.INSERT)) {
|
}
|
||||||
|
else if (modes.contains(MappingMode.INSERT)) {
|
||||||
return "i";
|
return "i";
|
||||||
} else if (modes.contains(MappingMode.NORMAL)) {
|
}
|
||||||
|
else if (modes.contains(MappingMode.NORMAL)) {
|
||||||
return "n";
|
return "n";
|
||||||
}
|
}
|
||||||
// TODO: Add more codes
|
// TODO: Add more codes
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull
|
private @NotNull List<AnAction> getActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
|
||||||
List<AnAction> getActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
|
|
||||||
final List<AnAction> results = new ArrayList<>();
|
final List<AnAction> results = new ArrayList<>();
|
||||||
results.addAll(getLocalActions(component, keyStroke));
|
results.addAll(getLocalActions(component, keyStroke));
|
||||||
results.addAll(getKeymapActions(keyStroke));
|
results.addAll(getKeymapActions(keyStroke));
|
||||||
@ -329,19 +326,17 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull
|
public @NotNull List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
|
||||||
List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
|
return getActions(((IjVimEditor)editor).getEditor().getComponent(), keyStroke).stream()
|
||||||
return getActions(((IjVimEditor) editor).getEditor().getComponent(), keyStroke).stream()
|
|
||||||
.map(IjNativeAction::new).collect(toList());
|
.map(IjNativeAction::new).collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
|
||||||
List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
|
|
||||||
final List<AnAction> results = new ArrayList<>();
|
final List<AnAction> results = new ArrayList<>();
|
||||||
final KeyboardShortcut keyStrokeShortcut = new KeyboardShortcut(keyStroke, null);
|
final KeyboardShortcut keyStrokeShortcut = new KeyboardShortcut(keyStroke, null);
|
||||||
for (Component c = component; c != null; c = c.getParent()) {
|
for (Component c = component; c != null; c = c.getParent()) {
|
||||||
if (c instanceof JComponent) {
|
if (c instanceof JComponent) {
|
||||||
final List<AnAction> actions = ActionUtil.getActions((JComponent) c);
|
final List<AnAction> actions = ActionUtil.getActions((JComponent)c);
|
||||||
for (AnAction action : actions) {
|
for (AnAction action : actions) {
|
||||||
if (action instanceof VimShortcutKeyAction) {
|
if (action instanceof VimShortcutKeyAction) {
|
||||||
continue;
|
continue;
|
||||||
@ -358,8 +353,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull List<AnAction> getKeymapActions(@NotNull KeyStroke keyStroke) {
|
||||||
List<AnAction> getKeymapActions(@NotNull KeyStroke keyStroke) {
|
|
||||||
final List<AnAction> results = new ArrayList<>();
|
final List<AnAction> results = new ArrayList<>();
|
||||||
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||||
for (String id : keymap.getActionIds(keyStroke)) {
|
for (String id : keymap.getActionIds(keyStroke)) {
|
||||||
|
@ -59,7 +59,7 @@ public class MarkGroup {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Mark createSystemMark(char ch, int line, int col, @NotNull VimEditor editor) {
|
public Mark createSystemMark(char ch, int line, int col, @NotNull VimEditor editor) {
|
||||||
Editor ijEditor = ((IjVimEditor) editor).getEditor();
|
Editor ijEditor = ((IjVimEditor)editor).getEditor();
|
||||||
@Nullable LineBookmark systemMark = SystemMarks.createOrGetSystemMark(ch, line, ijEditor);
|
@Nullable LineBookmark systemMark = SystemMarks.createOrGetSystemMark(ch, line, ijEditor);
|
||||||
if (systemMark == null) {
|
if (systemMark == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -387,8 +387,7 @@ internal class MotionGroup : VimMotionGroupBase() {
|
|||||||
} else if (cmd.action is TextObjectActionHandler) {
|
} else if (cmd.action is TextObjectActionHandler) {
|
||||||
val action = cmd.action as TextObjectActionHandler
|
val action = cmd.action as TextObjectActionHandler
|
||||||
val range =
|
val range =
|
||||||
action.getRange(editor.vim, caret.vim, IjEditorExecutionContext(context!!), cnt, raw, cmd.argument)
|
action.getRange(editor.vim, caret.vim, IjEditorExecutionContext(context!!), cnt, raw, cmd.argument) ?: return null
|
||||||
?: return null
|
|
||||||
start = range.startOffset
|
start = range.startOffset
|
||||||
end = range.endOffset
|
end = range.endOffset
|
||||||
if (cmd.isLinewiseMotion()) end--
|
if (cmd.isLinewiseMotion()) end--
|
||||||
|
@ -57,7 +57,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startSearchCommand(@NotNull VimEditor editor, ExecutionContext context, int count, char leader) {
|
public void startSearchCommand(@NotNull VimEditor editor, ExecutionContext context, int count, char leader) {
|
||||||
if (((IjVimEditor) editor).getEditor().isOneLineMode()) // Don't allow searching in one line editors
|
if (((IjVimEditor)editor).getEditor().isOneLineMode()) // Don't allow searching in one line editors
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -66,12 +66,11 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
String label = String.valueOf(leader);
|
String label = String.valueOf(leader);
|
||||||
|
|
||||||
ExEntryPanel panel = ExEntryPanel.getInstance();
|
ExEntryPanel panel = ExEntryPanel.getInstance();
|
||||||
panel.activate(((IjVimEditor) editor).getEditor(), ((DataContext) context.getContext()), label, initText, count);
|
panel.activate(((IjVimEditor)editor).getEditor(), ((DataContext)context.getContext()), label, initText, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull
|
public @NotNull String endSearchCommand() {
|
||||||
String endSearchCommand() {
|
|
||||||
ExEntryPanel panel = ExEntryPanel.getInstance();
|
ExEntryPanel panel = ExEntryPanel.getInstance();
|
||||||
panel.deactivate(true);
|
panel.deactivate(true);
|
||||||
|
|
||||||
@ -99,7 +98,8 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
panel.handleKey(stroke);
|
panel.handleKey(stroke);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
VimStateMachine.getInstance(editor).popModes();
|
VimStateMachine.getInstance(editor).popModes();
|
||||||
KeyHandler.getInstance().reset(editor);
|
KeyHandler.getInstance().reset(editor);
|
||||||
return false;
|
return false;
|
||||||
@ -127,11 +127,13 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
|
if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
|
||||||
|
|
||||||
VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
|
VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
|
||||||
} catch (ExException e) {
|
}
|
||||||
|
catch (ExException e) {
|
||||||
VimPlugin.showMessage(e.getMessage());
|
VimPlugin.showMessage(e.getMessage());
|
||||||
VimPlugin.indicateError();
|
VimPlugin.indicateError();
|
||||||
res = false;
|
res = false;
|
||||||
} catch (Exception bad) {
|
}
|
||||||
|
catch (Exception bad) {
|
||||||
ProcessGroup.logger.error(bad);
|
ProcessGroup.logger.error(bad);
|
||||||
VimPlugin.indicateError();
|
VimPlugin.indicateError();
|
||||||
res = false;
|
res = false;
|
||||||
@ -160,15 +162,16 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
|
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull
|
private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
|
||||||
String getRange(Editor editor, @NotNull Command cmd) {
|
|
||||||
String initText = "";
|
String initText = "";
|
||||||
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
|
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
|
||||||
initText = "'<,'>";
|
initText = "'<,'>";
|
||||||
} else if (cmd.getRawCount() > 0) {
|
}
|
||||||
|
else if (cmd.getRawCount() > 0) {
|
||||||
if (cmd.getCount() == 1) {
|
if (cmd.getCount() == 1) {
|
||||||
initText = ".";
|
initText = ".";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
initText = ".,.+" + (cmd.getCount() - 1);
|
initText = ".,.+" + (cmd.getCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,8 +179,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
return initText;
|
return initText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
public @Nullable String executeCommand(@NotNull VimEditor editor, @NotNull String command, @Nullable CharSequence input, @Nullable String currentDirectoryPath)
|
||||||
String executeCommand(@NotNull VimEditor editor, @NotNull String command, @Nullable CharSequence input, @Nullable String currentDirectoryPath)
|
|
||||||
throws ExecutionException, ProcessCanceledException {
|
throws ExecutionException, ProcessCanceledException {
|
||||||
|
|
||||||
// This is a much simplified version of how Vim does this. We're using stdin/stdout directly, while Vim will
|
// This is a much simplified version of how Vim does this. We're using stdin/stdout directly, while Vim will
|
||||||
@ -194,14 +196,14 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
|
|
||||||
// For Win32. See :help 'shellxescape'
|
// For Win32. See :help 'shellxescape'
|
||||||
final String escapedCommand = shellxquote.equals("(")
|
final String escapedCommand = shellxquote.equals("(")
|
||||||
? doEscape(command, shellxescape, "^")
|
? doEscape(command, shellxescape, "^")
|
||||||
: command;
|
: command;
|
||||||
// Required for Win32+cmd.exe, defaults to "(". See :help 'shellxquote'
|
// Required for Win32+cmd.exe, defaults to "(". See :help 'shellxquote'
|
||||||
final String quotedCommand = shellxquote.equals("(")
|
final String quotedCommand = shellxquote.equals("(")
|
||||||
? "(" + escapedCommand + ")"
|
? "(" + escapedCommand + ")"
|
||||||
: (shellxquote.equals("\"(")
|
: (shellxquote.equals("\"(")
|
||||||
? "\"(" + escapedCommand + ")\""
|
? "\"(" + escapedCommand + ")\""
|
||||||
: shellxquote + escapedCommand + shellxquote);
|
: shellxquote + escapedCommand + shellxquote);
|
||||||
|
|
||||||
final ArrayList<String> commands = new ArrayList<>();
|
final ArrayList<String> commands = new ArrayList<>();
|
||||||
commands.add(shell);
|
commands.add(shell);
|
||||||
@ -229,7 +231,8 @@ public class ProcessGroup extends VimProcessGroupBase {
|
|||||||
final BufferedWriter outputStreamWriter = new BufferedWriter(new OutputStreamWriter(handler.getProcessInput()));
|
final BufferedWriter outputStreamWriter = new BufferedWriter(new OutputStreamWriter(handler.getProcessInput()));
|
||||||
copy(charSequenceReader, outputStreamWriter);
|
copy(charSequenceReader, outputStreamWriter);
|
||||||
outputStreamWriter.close();
|
outputStreamWriter.close();
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,8 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
|
|||||||
final Element textElement = new Element("text");
|
final Element textElement = new Element("text");
|
||||||
VimPlugin.getXML().setSafeXmlText(textElement, text);
|
VimPlugin.getXML().setSafeXmlText(textElement, text);
|
||||||
registerElement.addContent(textElement);
|
registerElement.addContent(textElement);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger.trace("Save register as 'keys'");
|
logger.trace("Save register as 'keys'");
|
||||||
final Element keys = new Element("keys");
|
final Element keys = new Element("keys");
|
||||||
final List<KeyStroke> list = register.getKeys();
|
final List<KeyStroke> list = register.getKeys();
|
||||||
@ -101,11 +102,13 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
|
|||||||
if (text != null) {
|
if (text != null) {
|
||||||
logger.trace("Register data parsed");
|
logger.trace("Register data parsed");
|
||||||
register = new Register(key, type, text, Collections.emptyList());
|
register = new Register(key, type, text, Collections.emptyList());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger.trace("Cannot parse register data");
|
logger.trace("Cannot parse register data");
|
||||||
register = null;
|
register = null;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger.trace("Register has 'keys' element");
|
logger.trace("Register has 'keys' element");
|
||||||
final Element keysElement = registerElement.getChild("keys");
|
final Element keysElement = registerElement.getChild("keys");
|
||||||
final List<Element> keyElements = keysElement.getChildren("key");
|
final List<Element> keyElements = keysElement.getChildren("key");
|
||||||
@ -113,11 +116,11 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
|
|||||||
for (Element keyElement : keyElements) {
|
for (Element keyElement : keyElements) {
|
||||||
final int code = Integer.parseInt(keyElement.getAttributeValue("code"));
|
final int code = Integer.parseInt(keyElement.getAttributeValue("code"));
|
||||||
final int modifiers = Integer.parseInt(keyElement.getAttributeValue("mods"));
|
final int modifiers = Integer.parseInt(keyElement.getAttributeValue("mods"));
|
||||||
final char c = (char) Integer.parseInt(keyElement.getAttributeValue("char"));
|
final char c = (char)Integer.parseInt(keyElement.getAttributeValue("char"));
|
||||||
//noinspection MagicConstant
|
//noinspection MagicConstant
|
||||||
strokes.add(c == KeyEvent.CHAR_UNDEFINED ?
|
strokes.add(c == KeyEvent.CHAR_UNDEFINED ?
|
||||||
KeyStroke.getKeyStroke(code, modifiers) :
|
KeyStroke.getKeyStroke(code, modifiers) :
|
||||||
KeyStroke.getKeyStroke(c));
|
KeyStroke.getKeyStroke(c));
|
||||||
}
|
}
|
||||||
register = new Register(key, type, strokes);
|
register = new Register(key, type, strokes);
|
||||||
}
|
}
|
||||||
|
@ -110,18 +110,15 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* @return The pattern used for last search. Can be null
|
* @return The pattern used for last search. Can be null
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable String getLastSearchPattern() {
|
||||||
String getLastSearchPattern() {
|
|
||||||
return lastSearch;
|
return lastSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the last pattern used in substitution.
|
* Get the last pattern used in substitution.
|
||||||
*
|
|
||||||
* @return The pattern used for the last substitute command. Can be null
|
* @return The pattern used for the last substitute command. Can be null
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable String getLastSubstitutePattern() {
|
||||||
String getLastSubstitutePattern() {
|
|
||||||
return lastSubstitute;
|
return lastSubstitute;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,13 +127,10 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* @return The pattern last used for either searching or substitution. Can be null
|
* @return The pattern last used for either searching or substitution. Can be null
|
||||||
*/
|
*/
|
||||||
public @Nullable
|
public @Nullable String getLastUsedPattern() {
|
||||||
String getLastUsedPattern() {
|
|
||||||
switch (lastPatternIdx) {
|
switch (lastPatternIdx) {
|
||||||
case RE_SEARCH:
|
case RE_SEARCH: return lastSearch;
|
||||||
return lastSearch;
|
case RE_SUBST: return lastSubstitute;
|
||||||
case RE_SUBST:
|
|
||||||
return lastSubstitute;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -162,10 +156,10 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* <p>Also saves the text to the search register and history.</p>
|
* <p>Also saves the text to the search register and history.</p>
|
||||||
*
|
*
|
||||||
* @param pattern The pattern to remember
|
* @param pattern The pattern to remember
|
||||||
* @param which_pat Which pattern to save - RE_SEARCH, RE_SUBST or RE_BOTH
|
* @param which_pat Which pattern to save - RE_SEARCH, RE_SUBST or RE_BOTH
|
||||||
* @param isNewPattern Flag to indicate if the pattern is new, or comes from a last used pattern. True means to
|
* @param isNewPattern Flag to indicate if the pattern is new, or comes from a last used pattern. True means to
|
||||||
* update the last used pattern index
|
* update the last used pattern index
|
||||||
*/
|
*/
|
||||||
private void setLastUsedPattern(@NotNull String pattern, int which_pat, boolean isNewPattern) {
|
private void setLastUsedPattern(@NotNull String pattern, int which_pat, boolean isNewPattern) {
|
||||||
// Only update the last pattern with a new input pattern. Do not update if we're reusing the last pattern
|
// Only update the last pattern with a new input pattern. Do not update if we're reusing the last pattern
|
||||||
@ -189,10 +183,10 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
/**
|
/**
|
||||||
* Sets the last search state, purely for tests
|
* Sets the last search state, purely for tests
|
||||||
*
|
*
|
||||||
* @param editor The editor to update
|
* @param editor The editor to update
|
||||||
* @param pattern The pattern to save. This is the last search pattern, not the last substitute pattern
|
* @param pattern The pattern to save. This is the last search pattern, not the last substitute pattern
|
||||||
* @param patternOffset The pattern offset, e.g. `/{pattern}/{offset}`
|
* @param patternOffset The pattern offset, e.g. `/{pattern}/{offset}`
|
||||||
* @param direction The direction to search
|
* @param direction The direction to search
|
||||||
*/
|
*/
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public void setLastSearchState(@SuppressWarnings("unused") @NotNull Editor editor, @NotNull String pattern,
|
public void setLastSearchState(@SuppressWarnings("unused") @NotNull Editor editor, @NotNull String pattern,
|
||||||
@ -213,21 +207,21 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
/**
|
/**
|
||||||
* Find all occurrences of the pattern
|
* Find all occurrences of the pattern
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
|
||||||
* @param pattern The pattern to search for
|
|
||||||
* @param startLine The start line of the range to search for
|
|
||||||
* @param endLine The end line of the range to search for, or -1 for the whole document
|
|
||||||
* @param ignoreCase Case sensitive or insensitive searching
|
|
||||||
* @return A list of TextRange objects representing the results
|
|
||||||
* @deprecated Use SearchHelper#findAll instead. Kept for compatibility with existing plugins
|
* @deprecated Use SearchHelper#findAll instead. Kept for compatibility with existing plugins
|
||||||
|
*
|
||||||
|
* @param editor The editor to search in
|
||||||
|
* @param pattern The pattern to search for
|
||||||
|
* @param startLine The start line of the range to search for
|
||||||
|
* @param endLine The end line of the range to search for, or -1 for the whole document
|
||||||
|
* @param ignoreCase Case sensitive or insensitive searching
|
||||||
|
* @return A list of TextRange objects representing the results
|
||||||
*/
|
*/
|
||||||
@Deprecated()
|
@Deprecated()
|
||||||
public static @NotNull
|
public static @NotNull List<TextRange> findAll(@NotNull Editor editor,
|
||||||
List<TextRange> findAll(@NotNull Editor editor,
|
@NotNull String pattern,
|
||||||
@NotNull String pattern,
|
int startLine,
|
||||||
int startLine,
|
int endLine,
|
||||||
int endLine,
|
boolean ignoreCase) {
|
||||||
boolean ignoreCase) {
|
|
||||||
return SearchHelper.findAll(editor, pattern, startLine, endLine, ignoreCase);
|
return SearchHelper.findAll(editor, pattern, startLine, endLine, ignoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +246,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
* Can include a trailing offset, e.g. /{pattern}/{offset}, or multiple commands separated by a semicolon.
|
* Can include a trailing offset, e.g. /{pattern}/{offset}, or multiple commands separated by a semicolon.
|
||||||
* If the pattern is empty, the last used (search? substitute?) pattern (and offset?) is used.
|
* If the pattern is empty, the last used (search? substitute?) pattern (and offset?) is used.
|
||||||
* @param dir The direction to search
|
* @param dir The direction to search
|
||||||
* @return Offset to the next occurrence of the pattern or -1 if not found
|
* @return Offset to the next occurrence of the pattern or -1 if not found
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int processSearchCommand(@NotNull VimEditor editor, @NotNull String command, int startOffset, @NotNull Direction dir) {
|
public int processSearchCommand(@NotNull VimEditor editor, @NotNull String command, int startOffset, @NotNull Direction dir) {
|
||||||
@ -281,13 +275,16 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
end.inc();
|
end.inc();
|
||||||
patternOffset = end.toString();
|
patternOffset = end.toString();
|
||||||
if (logger.isDebugEnabled()) logger.debug("Pattern contains offset " + patternOffset);
|
if (logger.isDebugEnabled()) logger.debug("Pattern contains offset " + patternOffset);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger.debug("no offset");
|
logger.debug("no offset");
|
||||||
patternOffset = "";
|
patternOffset = "";
|
||||||
}
|
}
|
||||||
} else if (command.length() == 1) {
|
}
|
||||||
|
else if (command.length() == 1) {
|
||||||
patternOffset = "";
|
patternOffset = "";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
patternOffset = command.substring(1);
|
patternOffset = command.substring(1);
|
||||||
if (logger.isDebugEnabled()) logger.debug("offset=" + patternOffset);
|
if (logger.isDebugEnabled()) logger.debug("offset=" + patternOffset);
|
||||||
}
|
}
|
||||||
@ -340,7 +337,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
resetShowSearchHighlight();
|
resetShowSearchHighlight();
|
||||||
forceUpdateSearchHighlights();
|
forceUpdateSearchHighlights();
|
||||||
|
|
||||||
return findItOffset(((IjVimEditor) editor).getEditor(), startOffset, 1, lastDir);
|
return findItOffset(((IjVimEditor)editor).getEditor(), startOffset, 1, lastDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -359,7 +356,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
* @param patternOffset The offset applied to the range. Not used during searching, but used to populate lastPatternOffset
|
* @param patternOffset The offset applied to the range. Not used during searching, but used to populate lastPatternOffset
|
||||||
* @param startOffset The offset to start searching from
|
* @param startOffset The offset to start searching from
|
||||||
* @param direction The direction to search in
|
* @param direction The direction to search in
|
||||||
* @return The offset of the match or -1 if not found
|
* @return The offset of the match or -1 if not found
|
||||||
*/
|
*/
|
||||||
public int processSearchRange(@NotNull Editor editor, @NotNull String pattern, int patternOffset, int startOffset, @NotNull Direction direction) {
|
public int processSearchRange(@NotNull Editor editor, @NotNull String pattern, int patternOffset, int startOffset, @NotNull Direction direction) {
|
||||||
|
|
||||||
@ -404,22 +401,22 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* <p>Equivalent to normal.c:nv_ident</p>
|
* <p>Equivalent to normal.c:nv_ident</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param caret The caret to use to look for the current word
|
* @param caret The caret to use to look for the current word
|
||||||
* @param count Search for the nth occurrence of the current word
|
* @param count Search for the nth occurrence of the current word
|
||||||
* @param whole Include word boundaries in the search pattern
|
* @param whole Include word boundaries in the search pattern
|
||||||
* @param dir Which direction to search
|
* @param dir Which direction to search
|
||||||
* @return The offset of the result or the start of the word under the caret if not found. Returns -1 on error
|
* @return The offset of the result or the start of the word under the caret if not found. Returns -1 on error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int searchWord(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count, boolean whole, @NotNull Direction dir) {
|
public int searchWord(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count, boolean whole, @NotNull Direction dir) {
|
||||||
TextRange range = SearchHelper.findWordUnderCursor(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret());
|
TextRange range = SearchHelper.findWordUnderCursor(((IjVimEditor)editor).getEditor(), ((IjVimCaret)caret).getCaret());
|
||||||
if (range == null) {
|
if (range == null) {
|
||||||
logger.warn("No range was found");
|
logger.warn("No range was found");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull final Editor editor1 = ((IjVimEditor) editor).getEditor();
|
@NotNull final Editor editor1 = ((IjVimEditor)editor).getEditor();
|
||||||
final int start = range.getStartOffset();
|
final int start = range.getStartOffset();
|
||||||
final int end = range.getEndOffset();
|
final int end = range.getEndOffset();
|
||||||
final String pattern = SearchHelper.makeSearchPattern(
|
final String pattern = SearchHelper.makeSearchPattern(
|
||||||
@ -437,7 +434,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
resetShowSearchHighlight();
|
resetShowSearchHighlight();
|
||||||
forceUpdateSearchHighlights();
|
forceUpdateSearchHighlights();
|
||||||
|
|
||||||
final int offset = findItOffset(((IjVimEditor) editor).getEditor(), range.getStartOffset(), count, lastDir);
|
final int offset = findItOffset(((IjVimEditor)editor).getEditor(), range.getStartOffset(), count, lastDir);
|
||||||
return offset == -1 ? range.getStartOffset() : offset;
|
return offset == -1 ? range.getStartOffset() : offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,14 +444,14 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
* <p>Searches for RE_LAST, including last used pattern offset. Direction is the same as the last used direction.
|
* <p>Searches for RE_LAST, including last used pattern offset. Direction is the same as the last used direction.
|
||||||
* E.g. `?foo` followed by `n` will search backwards. scanwrap and ignorecase come from options.</p>
|
* E.g. `?foo` followed by `n` will search backwards. scanwrap and ignorecase come from options.</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param caret Used to get the offset to start searching from
|
* @param caret Used to get the offset to start searching from
|
||||||
* @param count Find the nth occurrence
|
* @param count Find the nth occurrence
|
||||||
* @return The offset of the next match, or -1 if not found
|
* @return The offset of the next match, or -1 if not found
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int searchNext(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count) {
|
public int searchNext(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count) {
|
||||||
return searchNextWithDirection(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), count, lastDir);
|
return searchNextWithDirection(((IjVimEditor)editor).getEditor(), ((IjVimCaret)caret).getCaret(), count, lastDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -463,15 +460,15 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
* <p>Searches for RE_LAST, including last used pattern offset. Direction is the opposite of the last used direction.
|
* <p>Searches for RE_LAST, including last used pattern offset. Direction is the opposite of the last used direction.
|
||||||
* E.g. `?foo` followed by `N` will be forwards. scanwrap and ignorecase come from options.</p>
|
* E.g. `?foo` followed by `N` will be forwards. scanwrap and ignorecase come from options.</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param caret Used to get the offset to starting searching from
|
* @param caret Used to get the offset to starting searching from
|
||||||
* @param count Find the nth occurrence
|
* @param count Find the nth occurrence
|
||||||
* @return The offset of the next match, or -1 if not found
|
* @return The offset of the next match, or -1 if not found
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int searchPrevious(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count) {
|
public int searchPrevious(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count) {
|
||||||
return searchNextWithDirection(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), count,
|
return searchNextWithDirection(((IjVimEditor)editor).getEditor(), ((IjVimCaret)caret).getCaret(), count,
|
||||||
lastDir.reverse());
|
lastDir.reverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
// See normal.c:nv_next
|
// See normal.c:nv_next
|
||||||
@ -508,12 +505,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* <p>See ex_cmds.c:ex_substitute</p>
|
* <p>See ex_cmds.c:ex_substitute</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param caret The caret to use for initial search offset, and to move for interactive substitution
|
* @param caret The caret to use for initial search offset, and to move for interactive substitution
|
||||||
* @param range Only search and substitute within the given line range. Must be valid
|
* @param range Only search and substitute within the given line range. Must be valid
|
||||||
* @param excmd The command part of the ex command line, e.g. `s` or `substitute`, or `~`
|
* @param excmd The command part of the ex command line, e.g. `s` or `substitute`, or `~`
|
||||||
* @param exarg The argument to the substitute command, such as `/{pattern}/{string}/[flags]`
|
* @param exarg The argument to the substitute command, such as `/{pattern}/{string}/[flags]`
|
||||||
* @return True if the substitution succeeds, false on error. Will succeed even if nothing is modified
|
* @return True if the substitution succeeds, false on error. Will succeed even if nothing is modified
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@RWLockLabel.SelfSynchronized
|
@RWLockLabel.SelfSynchronized
|
||||||
@ -534,7 +531,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
int which_pat;
|
int which_pat;
|
||||||
if ("~".equals(excmd)) {
|
if ("~".equals(excmd)) {
|
||||||
which_pat = RE_LAST; /* use last used regexp */
|
which_pat = RE_LAST; /* use last used regexp */
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
which_pat = RE_SUBST; /* use last substitute regexp */
|
which_pat = RE_SUBST; /* use last substitute regexp */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +564,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
pat = new CharPointer(""); /* empty search pattern */
|
pat = new CharPointer(""); /* empty search pattern */
|
||||||
delimiter = cmd.charAt(); /* remember delimiter character */
|
delimiter = cmd.charAt(); /* remember delimiter character */
|
||||||
cmd.inc();
|
cmd.inc();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* find the end of the regexp */
|
/* find the end of the regexp */
|
||||||
which_pat = RE_LAST; /* use last used regexp */
|
which_pat = RE_LAST; /* use last used regexp */
|
||||||
delimiter = cmd.charAt(); /* remember delimiter character */
|
delimiter = cmd.charAt(); /* remember delimiter character */
|
||||||
@ -594,7 +593,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
}
|
}
|
||||||
cmd.inc();
|
cmd.inc();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
/* use previous pattern and substitution */
|
/* use previous pattern and substitution */
|
||||||
if (lastReplace == null) {
|
if (lastReplace == null) {
|
||||||
/* there is no previous command */
|
/* there is no previous command */
|
||||||
@ -610,7 +610,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*/
|
*/
|
||||||
if (cmd.charAt() == '&') {
|
if (cmd.charAt() == '&') {
|
||||||
cmd.inc();
|
cmd.inc();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// :h :&& - "Note that :s and :& don't keep the flags"
|
// :h :&& - "Note that :s and :& don't keep the flags"
|
||||||
do_all = options(injector, editor).isSet(OptionConstants.gdefault);
|
do_all = options(injector, editor).isSet(OptionConstants.gdefault);
|
||||||
do_ask = false;
|
do_ask = false;
|
||||||
@ -624,20 +625,26 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*/
|
*/
|
||||||
if (cmd.charAt() == 'g') {
|
if (cmd.charAt() == 'g') {
|
||||||
do_all = !do_all;
|
do_all = !do_all;
|
||||||
} else if (cmd.charAt() == 'c') {
|
}
|
||||||
|
else if (cmd.charAt() == 'c') {
|
||||||
do_ask = !do_ask;
|
do_ask = !do_ask;
|
||||||
} else if (cmd.charAt() == 'e') {
|
}
|
||||||
|
else if (cmd.charAt() == 'e') {
|
||||||
do_error = !do_error;
|
do_error = !do_error;
|
||||||
} else if (cmd.charAt() == 'r') {
|
}
|
||||||
|
else if (cmd.charAt() == 'r') {
|
||||||
/* use last used regexp */
|
/* use last used regexp */
|
||||||
which_pat = RE_LAST;
|
which_pat = RE_LAST;
|
||||||
} else if (cmd.charAt() == 'i') {
|
}
|
||||||
|
else if (cmd.charAt() == 'i') {
|
||||||
/* ignore case */
|
/* ignore case */
|
||||||
do_ic = 'i';
|
do_ic = 'i';
|
||||||
} else if (cmd.charAt() == 'I') {
|
}
|
||||||
|
else if (cmd.charAt() == 'I') {
|
||||||
/* don't ignore case */
|
/* don't ignore case */
|
||||||
do_ic = 'I';
|
do_ic = 'I';
|
||||||
} else if (cmd.charAt() != 'p' && cmd.charAt() != 'l' && cmd.charAt() != '#' && cmd.charAt() != 'n') {
|
}
|
||||||
|
else if (cmd.charAt() != 'p' && cmd.charAt() != 'l' && cmd.charAt() != '#' && cmd.charAt() != 'n') {
|
||||||
// TODO: Support printing last changed line, with options for line number/list format
|
// TODO: Support printing last changed line, with options for line number/list format
|
||||||
// TODO: Support 'n' to report number of matches without substituting
|
// TODO: Support 'n' to report number of matches without substituting
|
||||||
break;
|
break;
|
||||||
@ -677,7 +684,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<Boolean, Triple<Object, String, Object>> booleanregmmatch_tPair = search_regcomp(pat, which_pat,
|
Pair<Boolean, Triple<Object, String, Object>> booleanregmmatch_tPair = search_regcomp(pat, which_pat,
|
||||||
RE_SUBST);
|
RE_SUBST);
|
||||||
if (!booleanregmmatch_tPair.getFirst()) {
|
if (!booleanregmmatch_tPair.getFirst()) {
|
||||||
if (do_error) {
|
if (do_error) {
|
||||||
VimPlugin.showMessage(MessageHelper.message(Msg.e_invcmd));
|
VimPlugin.showMessage(MessageHelper.message(Msg.e_invcmd));
|
||||||
@ -692,7 +699,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
/* the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase' */
|
/* the 'i' or 'I' flag overrules 'ignorecase' and 'smartcase' */
|
||||||
if (do_ic == 'i') {
|
if (do_ic == 'i') {
|
||||||
regmatch.rmm_ic = true;
|
regmatch.rmm_ic = true;
|
||||||
} else if (do_ic == 'I') {
|
}
|
||||||
|
else if (do_ic == 'I') {
|
||||||
regmatch.rmm_ic = false;
|
regmatch.rmm_ic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,9 +802,9 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
caret.moveToOffset(startoff);
|
caret.moveToOffset(startoff);
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
try {
|
try {
|
||||||
match = expression
|
match = expression
|
||||||
.evaluate(editor, injector.getExecutionContextManager().onEditor(editor, null), parent)
|
.evaluate(editor, injector.getExecutionContextManager().onEditor(editor, null), parent)
|
||||||
.toInsertableString();
|
.toInsertableString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
exceptions.add((ExException) e);
|
exceptions.add((ExException) e);
|
||||||
match = "";
|
match = "";
|
||||||
@ -805,7 +813,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
|
|
||||||
String finalMatch = match;
|
String finalMatch = match;
|
||||||
ApplicationManager.getApplication().runWriteAction(() -> ((IjVimEditor) editor).getEditor().getDocument().replaceString(startoff, endoff,
|
ApplicationManager.getApplication().runWriteAction(() -> ((IjVimEditor) editor).getEditor().getDocument().replaceString(startoff, endoff,
|
||||||
finalMatch));
|
finalMatch));
|
||||||
lastMatch = startoff;
|
lastMatch = startoff;
|
||||||
int newend = startoff + match.length();
|
int newend = startoff + match.length();
|
||||||
newpos = CharacterPosition.Companion.fromOffset(((IjVimEditor) editor).getEditor(), newend);
|
newpos = CharacterPosition.Companion.fromOffset(((IjVimEditor) editor).getEditor(), newend);
|
||||||
@ -822,14 +830,17 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
if (newpos != null) {
|
if (newpos != null) {
|
||||||
lnum = newpos.line;
|
lnum = newpos.line;
|
||||||
searchcol = newpos.column;
|
searchcol = newpos.column;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
searchcol = endpos.column;
|
searchcol = endpos.column;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
searchcol = 0;
|
searchcol = 0;
|
||||||
lnum++;
|
lnum++;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lnum++;
|
lnum++;
|
||||||
searchcol = 0;
|
searchcol = 0;
|
||||||
}
|
}
|
||||||
@ -839,7 +850,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
if (lastMatch != -1) {
|
if (lastMatch != -1) {
|
||||||
caret.moveToOffset(
|
caret.moveToOffset(
|
||||||
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, editor.offsetToBufferPosition(lastMatch).getLine()));
|
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, editor.offsetToBufferPosition(lastMatch).getLine()));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
VimPlugin.showMessage(MessageHelper.message(Msg.e_patnotf2, pattern));
|
VimPlugin.showMessage(MessageHelper.message(Msg.e_patnotf2, pattern));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -882,8 +894,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
|
|
||||||
//public Pair<Boolean, Triple<RegExp.regmmatch_T, String, RegExp>> search_regcomp(CharPointer pat,
|
//public Pair<Boolean, Triple<RegExp.regmmatch_T, String, RegExp>> search_regcomp(CharPointer pat,
|
||||||
public Pair<Boolean, Triple<Object, String, Object>> search_regcomp(CharPointer pat,
|
public Pair<Boolean, Triple<Object, String, Object>> search_regcomp(CharPointer pat,
|
||||||
int which_pat,
|
int which_pat,
|
||||||
int patSave) {
|
int patSave) {
|
||||||
// We don't need to worry about lastIgnoreSmartCase, it's always false. Vim resets after checking, and it only sets
|
// We don't need to worry about lastIgnoreSmartCase, it's always false. Vim resets after checking, and it only sets
|
||||||
// it to true when searching for a word with `*`, `#`, `g*`, etc.
|
// it to true when searching for a word with `*`, `#`, `g*`, etc.
|
||||||
boolean isNewPattern = true;
|
boolean isNewPattern = true;
|
||||||
@ -910,7 +922,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
VimPlugin.showMessage(errorMessage);
|
VimPlugin.showMessage(errorMessage);
|
||||||
return new Pair<>(false, null);
|
return new Pair<>(false, null);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
pattern = pat.toString();
|
pattern = pat.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,8 +945,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
return new Pair<>(true, new Triple<>(regmatch, pattern, sp));
|
return new Pair<>(true, new Triple<>(regmatch, pattern, sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull ReplaceConfirmationChoice confirmChoice(@NotNull Editor editor, @NotNull String match, @NotNull Caret caret, int startoff) {
|
||||||
ReplaceConfirmationChoice confirmChoice(@NotNull Editor editor, @NotNull String match, @NotNull Caret caret, int startoff) {
|
|
||||||
final Ref<ReplaceConfirmationChoice> result = Ref.create(ReplaceConfirmationChoice.QUIT);
|
final Ref<ReplaceConfirmationChoice> result = Ref.create(ReplaceConfirmationChoice.QUIT);
|
||||||
final Function1<KeyStroke, Boolean> keyStrokeProcessor = key -> {
|
final Function1<KeyStroke, Boolean> keyStrokeProcessor = key -> {
|
||||||
final ReplaceConfirmationChoice choice;
|
final ReplaceConfirmationChoice choice;
|
||||||
@ -963,11 +975,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for this method
|
// XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for this method
|
||||||
final ExEntryPanel exEntryPanel = ExEntryPanel.getInstanceWithoutShortcuts();
|
final ExEntryPanel exEntryPanel = ExEntryPanel.getInstanceWithoutShortcuts();
|
||||||
ExecutionContext.Editor context = injector.getExecutionContextManager().onEditor(new IjVimEditor(editor), null);
|
ExecutionContext.Editor context = injector.getExecutionContextManager().onEditor(new IjVimEditor(editor), null);
|
||||||
exEntryPanel.activate(editor, ((IjEditorExecutionContext) context).getContext(), MessageHelper.message("replace.with.0", match), "", 1);
|
exEntryPanel.activate(editor, ((IjEditorExecutionContext)context).getContext(), MessageHelper.message("replace.with.0", match), "", 1);
|
||||||
new IjVimCaret(caret).moveToOffset(startoff);
|
new IjVimCaret(caret).moveToOffset(startoff);
|
||||||
ModalEntry.INSTANCE.activate(new IjVimEditor(editor), keyStrokeProcessor);
|
ModalEntry.INSTANCE.activate(new IjVimEditor(editor), keyStrokeProcessor);
|
||||||
exEntryPanel.deactivate(true, false);
|
exEntryPanel.deactivate(true, false);
|
||||||
@ -991,20 +1004,20 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
* caret is inside the range of an occurrence, will return that instance. Uses the last used search pattern. Does not
|
* caret is inside the range of an occurrence, will return that instance. Uses the last used search pattern. Does not
|
||||||
* update any other state. Direction is explicit, not from state.</p>
|
* update any other state. Direction is explicit, not from state.</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param count Find the nth occurrence
|
* @param count Find the nth occurrence
|
||||||
* @param forwards Search forwards or backwards
|
* @param forwards Search forwards or backwards
|
||||||
* @return The TextRange of the next occurrence or null if not found
|
* @return The TextRange of the next occurrence or null if not found
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public @Nullable
|
public @Nullable TextRange getNextSearchRange(@NotNull VimEditor editor, int count, boolean forwards) {
|
||||||
TextRange getNextSearchRange(@NotNull VimEditor editor, int count, boolean forwards) {
|
|
||||||
editor.removeSecondaryCarets();
|
editor.removeSecondaryCarets();
|
||||||
TextRange current = findUnderCaret(editor);
|
TextRange current = findUnderCaret(editor);
|
||||||
|
|
||||||
if (current == null || CommandStateHelper.inVisualMode(((IjVimEditor) editor).getEditor()) && atEdgeOfGnRange(current, ((IjVimEditor) editor).getEditor(), forwards)) {
|
if (current == null || CommandStateHelper.inVisualMode(((IjVimEditor)editor).getEditor()) && atEdgeOfGnRange(current, ((IjVimEditor)editor).getEditor(), forwards)) {
|
||||||
current = findNextSearchForGn(editor, count, forwards);
|
current = findNextSearchForGn(editor, count, forwards);
|
||||||
} else if (count > 1) {
|
}
|
||||||
|
else if (count > 1) {
|
||||||
current = findNextSearchForGn(editor, count - 1, forwards);
|
current = findNextSearchForGn(editor, count - 1, forwards);
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
@ -1014,13 +1027,13 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
int currentPosition = editor.getCaretModel().getOffset();
|
int currentPosition = editor.getCaretModel().getOffset();
|
||||||
if (forwards) {
|
if (forwards) {
|
||||||
return nextRange.getEndOffset() - VimPlugin.getVisualMotion().getSelectionAdj() == currentPosition;
|
return nextRange.getEndOffset() - VimPlugin.getVisualMotion().getSelectionAdj() == currentPosition;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return nextRange.getStartOffset() == currentPosition;
|
return nextRange.getStartOffset() == currentPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable TextRange findNextSearchForGn(@NotNull VimEditor editor, int count, boolean forwards) {
|
||||||
TextRange findNextSearchForGn(@NotNull VimEditor editor, int count, boolean forwards) {
|
|
||||||
if (forwards) {
|
if (forwards) {
|
||||||
final EnumSet<SearchOptions> searchOptions = EnumSet.of(SearchOptions.WRAP, SearchOptions.WHOLE_FILE);
|
final EnumSet<SearchOptions> searchOptions = EnumSet.of(SearchOptions.WRAP, SearchOptions.WHOLE_FILE);
|
||||||
return VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), editor.primaryCaret().getOffset().getPoint(), count, searchOptions);
|
return VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), editor.primaryCaret().getOffset().getPoint(), count, searchOptions);
|
||||||
@ -1045,7 +1058,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
final TextRange foundBackward = VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), offset, count, searchOptions);
|
final TextRange foundBackward = VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), offset, count, searchOptions);
|
||||||
if (foundBackward == null) return null;
|
if (foundBackward == null) return null;
|
||||||
int startOffset = foundBackward.getStartOffset() - 1;
|
int startOffset = foundBackward.getStartOffset() - 1;
|
||||||
if (startOffset < 0) startOffset = (int) editor.fileSize();
|
if (startOffset < 0) startOffset = (int)editor.fileSize();
|
||||||
searchOptions.remove(SearchOptions.BACKWARDS);
|
searchOptions.remove(SearchOptions.BACKWARDS);
|
||||||
return VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), startOffset, 1, searchOptions);
|
return VimInjectorKt.getInjector().getSearchHelper().findPattern(editor, getLastUsedPattern(), startOffset, 1, searchOptions);
|
||||||
}
|
}
|
||||||
@ -1125,7 +1138,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
public static DocumentSearchListener INSTANCE = new DocumentSearchListener();
|
public static DocumentSearchListener INSTANCE = new DocumentSearchListener();
|
||||||
|
|
||||||
@Contract(pure = true)
|
@Contract(pure = true)
|
||||||
private DocumentSearchListener() {
|
private DocumentSearchListener () {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1187,11 +1200,11 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
*
|
*
|
||||||
* <p>See search.c:do_search (and a little bit of normal.c:normal_search)</p>
|
* <p>See search.c:do_search (and a little bit of normal.c:normal_search)</p>
|
||||||
*
|
*
|
||||||
* @param editor The editor to search in
|
* @param editor The editor to search in
|
||||||
* @param startOffset The offset to search from
|
* @param startOffset The offset to search from
|
||||||
* @param count Find the nth occurrence
|
* @param count Find the nth occurrence
|
||||||
* @param dir The direction to search in
|
* @param dir The direction to search in
|
||||||
* @return The offset to the occurrence or -1 if not found
|
* @return The offset to the occurrence or -1 if not found
|
||||||
*/
|
*/
|
||||||
private int findItOffset(@NotNull Editor editor, int startOffset, int count, Direction dir) {
|
private int findItOffset(@NotNull Editor editor, int startOffset, int count, Direction dir) {
|
||||||
boolean wrap = globalOptions(injector).isSet(OptionConstants.wrapscan);
|
boolean wrap = globalOptions(injector).isSet(OptionConstants.wrapscan);
|
||||||
@ -1271,7 +1284,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
|
|
||||||
// TODO: Don't move the caret!
|
// TODO: Don't move the caret!
|
||||||
res = VimPlugin.getMotion().moveCaretToLineStart(new IjVimEditor(editor), newLine);
|
res = VimPlugin.getMotion().moveCaretToLineStart(new IjVimEditor(editor), newLine);
|
||||||
} else if (hasEndOffset || offset != 0) {
|
}
|
||||||
|
else if (hasEndOffset || offset != 0) {
|
||||||
int base = hasEndOffset ? range.getEndOffset() - 1 : range.getStartOffset();
|
int base = hasEndOffset ? range.getEndOffset() - 1 : range.getStartOffset();
|
||||||
res = Math.max(0, Math.min(base + offset, EditorHelperRt.getFileSize(editor) - 1));
|
res = Math.max(0, Math.min(base + offset, EditorHelperRt.getFileSize(editor) - 1));
|
||||||
}
|
}
|
||||||
@ -1281,9 +1295,11 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
final Direction nextDir;
|
final Direction nextDir;
|
||||||
if (lastPatternOffset.charAt(ppos + 1) == '/') {
|
if (lastPatternOffset.charAt(ppos + 1) == '/') {
|
||||||
nextDir = Direction.FORWARDS;
|
nextDir = Direction.FORWARDS;
|
||||||
} else if (lastPatternOffset.charAt(ppos + 1) == '?') {
|
}
|
||||||
|
else if (lastPatternOffset.charAt(ppos + 1) == '?') {
|
||||||
nextDir = Direction.BACKWARDS;
|
nextDir = Direction.BACKWARDS;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1339,14 +1355,16 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
final String lastPatternText = getSafeChildText(search, "last-pattern");
|
final String lastPatternText = getSafeChildText(search, "last-pattern");
|
||||||
if (lastPatternText == null || lastPatternText.equals(lastSearch)) {
|
if (lastPatternText == null || lastPatternText.equals(lastSearch)) {
|
||||||
lastPatternIdx = RE_SEARCH;
|
lastPatternIdx = RE_SEARCH;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
lastPatternIdx = RE_SUBST;
|
lastPatternIdx = RE_SUBST;
|
||||||
}
|
}
|
||||||
|
|
||||||
Element dir = search.getChild("last-dir");
|
Element dir = search.getChild("last-dir");
|
||||||
try {
|
try {
|
||||||
lastDir = Direction.Companion.fromInt(Integer.parseInt(dir.getText()));
|
lastDir = Direction.Companion.fromInt(Integer.parseInt(dir.getText()));
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
lastDir = Direction.FORWARDS;
|
lastDir = Direction.FORWARDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1359,15 +1377,13 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable
|
private static @Nullable String getSafeChildText(@NotNull Element element, @NotNull String name) {
|
||||||
String getSafeChildText(@NotNull Element element, @NotNull String name) {
|
|
||||||
final Element child = element.getChild(name);
|
final Element child = element.getChild(name);
|
||||||
return child != null ? VimPlugin.getXML().getSafeXmlText(child) : null;
|
return child != null ? VimPlugin.getXML().getSafeXmlText(child) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("SameParameterValue")
|
@SuppressWarnings("SameParameterValue")
|
||||||
private static @NotNull
|
private static @NotNull String getSafeChildText(@NotNull Element element, @NotNull String name, @NotNull String defaultValue) {
|
||||||
String getSafeChildText(@NotNull Element element, @NotNull String name, @NotNull String defaultValue) {
|
|
||||||
final Element child = element.getChild(name);
|
final Element child = element.getChild(name);
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
final String value = VimPlugin.getXML().getSafeXmlText(child);
|
final String value = VimPlugin.getXML().getSafeXmlText(child);
|
||||||
@ -1405,18 +1421,13 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
|||||||
// The trailing tilde tracks which was the last used pattern, but line/end/off is only used for search, not substitution
|
// The trailing tilde tracks which was the last used pattern, but line/end/off is only used for search, not substitution
|
||||||
// Search values can contain new lines, etc. Vim saves these as CTRL chars, e.g. ^M
|
// Search values can contain new lines, etc. Vim saves these as CTRL chars, e.g. ^M
|
||||||
// Before saving, Vim reads existing viminfo, merges and writes
|
// Before saving, Vim reads existing viminfo, merges and writes
|
||||||
private @Nullable
|
private @Nullable String lastSearch; // Pattern used for last search command (`/`)
|
||||||
String lastSearch; // Pattern used for last search command (`/`)
|
private @Nullable String lastSubstitute; // Pattern used for last substitute command (`:s`)
|
||||||
private @Nullable
|
|
||||||
String lastSubstitute; // Pattern used for last substitute command (`:s`)
|
|
||||||
private int lastPatternIdx; // Which pattern was used last? RE_SEARCH or RE_SUBST?
|
private int lastPatternIdx; // Which pattern was used last? RE_SEARCH or RE_SUBST?
|
||||||
private @Nullable
|
private @Nullable String lastReplace; // `# Last Substitute String` from viminfo
|
||||||
String lastReplace; // `# Last Substitute String` from viminfo
|
private @NotNull String lastPatternOffset = ""; // /{pattern}/{offset}. Do not confuse with caret offset!
|
||||||
private @NotNull
|
|
||||||
String lastPatternOffset = ""; // /{pattern}/{offset}. Do not confuse with caret offset!
|
|
||||||
private boolean lastIgnoreSmartCase;
|
private boolean lastIgnoreSmartCase;
|
||||||
private @NotNull
|
private @NotNull Direction lastDir = Direction.FORWARDS;
|
||||||
Direction lastDir = Direction.FORWARDS;
|
|
||||||
private boolean showSearchHighlight = globalOptions(injector).isSet(OptionConstants.hlsearch);
|
private boolean showSearchHighlight = globalOptions(injector).isSet(OptionConstants.hlsearch);
|
||||||
|
|
||||||
private boolean do_all = false; /* do multiple substitutions per line */
|
private boolean do_all = false; /* do multiple substitutions per line */
|
||||||
|
@ -31,7 +31,6 @@ internal class VimJumpServiceImpl : VimJumpServiceBase(), PersistentStateCompone
|
|||||||
companion object {
|
companion object {
|
||||||
private val logger = vimLogger<VimJumpServiceImpl>()
|
private val logger = vimLogger<VimJumpServiceImpl>()
|
||||||
}
|
}
|
||||||
|
|
||||||
override var lastJumpTimeStamp: Long = 0
|
override var lastJumpTimeStamp: Long = 0
|
||||||
|
|
||||||
override fun includeCurrentCommandAsNavigation(editor: VimEditor) {
|
override fun includeCurrentCommandAsNavigation(editor: VimEditor) {
|
||||||
|
@ -37,7 +37,7 @@ import java.util.*;
|
|||||||
public class WindowGroup extends WindowGroupBase {
|
public class WindowGroup extends WindowGroupBase {
|
||||||
@Override
|
@Override
|
||||||
public void closeCurrentWindow(@NotNull ExecutionContext context) {
|
public void closeCurrentWindow(@NotNull ExecutionContext context) {
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager((DataContext) context.getContext());
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager((DataContext)context.getContext());
|
||||||
final EditorWindow window = fileEditorManager.getSplitters().getCurrentWindow();
|
final EditorWindow window = fileEditorManager.getSplitters().getCurrentWindow();
|
||||||
if (window != null) {
|
if (window != null) {
|
||||||
window.closeAllExcept(null);
|
window.closeAllExcept(null);
|
||||||
@ -46,7 +46,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeAllExceptCurrent(@NotNull ExecutionContext context) {
|
public void closeAllExceptCurrent(@NotNull ExecutionContext context) {
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
|
||||||
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
||||||
for (final EditorWindow window : fileEditorManager.getWindows()) {
|
for (final EditorWindow window : fileEditorManager.getWindows()) {
|
||||||
if (window != current) {
|
if (window != current) {
|
||||||
@ -61,7 +61,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectNextWindow(@NotNull ExecutionContext context) {
|
public void selectNextWindow(@NotNull ExecutionContext context) {
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
|
||||||
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
EditorWindow nextWindow = fileEditorManager.getNextWindow(current);
|
EditorWindow nextWindow = fileEditorManager.getNextWindow(current);
|
||||||
@ -73,7 +73,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPreviousWindow(@NotNull ExecutionContext context) {
|
public void selectPreviousWindow(@NotNull ExecutionContext context) {
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
|
||||||
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
final EditorWindow current = fileEditorManager.getCurrentWindow();
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
EditorWindow prevWindow = fileEditorManager.getPrevWindow(current);
|
EditorWindow prevWindow = fileEditorManager.getPrevWindow(current);
|
||||||
@ -85,7 +85,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectWindow(@NotNull ExecutionContext context, int index) {
|
public void selectWindow(@NotNull ExecutionContext context, int index) {
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
|
||||||
final EditorWindow[] windows = fileEditorManager.getWindows();
|
final EditorWindow[] windows = fileEditorManager.getWindows();
|
||||||
if (index - 1 < windows.length) {
|
if (index - 1 < windows.length) {
|
||||||
windows[index - 1].setAsCurrentWindow(true);
|
windows[index - 1].setAsCurrentWindow(true);
|
||||||
@ -94,12 +94,12 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void splitWindowHorizontal(@NotNull ExecutionContext context, @NotNull String filename) {
|
public void splitWindowHorizontal(@NotNull ExecutionContext context, @NotNull String filename) {
|
||||||
splitWindow(SwingConstants.HORIZONTAL, (DataContext) context.getContext(), filename);
|
splitWindow(SwingConstants.HORIZONTAL, (DataContext)context.getContext(), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void splitWindowVertical(@NotNull ExecutionContext context, @NotNull String filename) {
|
public void splitWindowVertical(@NotNull ExecutionContext context, @NotNull String filename) {
|
||||||
splitWindow(SwingConstants.VERTICAL, (DataContext) context.getContext(), filename);
|
splitWindow(SwingConstants.VERTICAL, (DataContext)context.getContext(), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -107,8 +107,8 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
@RequiresReadLock
|
@RequiresReadLock
|
||||||
public void selectWindowInRow(@NotNull VimCaret caret, @NotNull ExecutionContext context, int relativePosition, boolean vertical) {
|
public void selectWindowInRow(@NotNull VimCaret caret, @NotNull ExecutionContext context, int relativePosition, boolean vertical) {
|
||||||
final Caret ijCaret = ((IjVimCaret) caret).getCaret();
|
final Caret ijCaret = ((IjVimCaret) caret).getCaret();
|
||||||
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
|
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
|
||||||
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
|
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
|
||||||
if (currentWindow != null) {
|
if (currentWindow != null) {
|
||||||
final EditorWindow[] windows = fileEditorManager.getWindows();
|
final EditorWindow[] windows = fileEditorManager.getWindows();
|
||||||
final List<EditorWindow> row = findWindowsInRow(ijCaret, currentWindow, Arrays.asList(windows), vertical);
|
final List<EditorWindow> row = findWindowsInRow(ijCaret, currentWindow, Arrays.asList(windows), vertical);
|
||||||
@ -124,10 +124,9 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
windows.get(normalized).setAsCurrentWindow(true);
|
windows.get(normalized).setAsCurrentWindow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
|
||||||
List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
|
@NotNull EditorWindow editorWindow,
|
||||||
@NotNull EditorWindow editorWindow,
|
@NotNull List<EditorWindow> windows, final boolean vertical) {
|
||||||
@NotNull List<EditorWindow> windows, final boolean vertical) {
|
|
||||||
final Point anchorPoint = getCaretPoint(caret);
|
final Point anchorPoint = getCaretPoint(caret);
|
||||||
if (anchorPoint != null) {
|
if (anchorPoint != null) {
|
||||||
final List<EditorWindow> result = new ArrayList<>();
|
final List<EditorWindow> result = new ArrayList<>();
|
||||||
@ -156,8 +155,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
return Collections.singletonList(editorWindow);
|
return Collections.singletonList(editorWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull FileEditorManagerEx getFileEditorManager(@NotNull DataContext context) {
|
||||||
FileEditorManagerEx getFileEditorManager(@NotNull DataContext context) {
|
|
||||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||||
return FileEditorManagerEx.getInstanceEx(Objects.requireNonNull(project));
|
return FileEditorManagerEx.getInstanceEx(Objects.requireNonNull(project));
|
||||||
}
|
}
|
||||||
@ -182,8 +180,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull Point getCaretPoint(@NotNull Caret caret) {
|
||||||
Point getCaretPoint(@NotNull Caret caret) {
|
|
||||||
final Editor editor = caret.getEditor();
|
final Editor editor = caret.getEditor();
|
||||||
final Point caretLocation = editor.logicalPositionToXY(caret.getLogicalPosition());
|
final Point caretLocation = editor.logicalPositionToXY(caret.getLogicalPosition());
|
||||||
Point caretScreenLocation = editor.getContentComponent().getLocationOnScreen();
|
Point caretScreenLocation = editor.getContentComponent().getLocationOnScreen();
|
||||||
@ -191,8 +188,7 @@ public class WindowGroup extends WindowGroupBase {
|
|||||||
return caretScreenLocation;
|
return caretScreenLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable
|
private static @Nullable Rectangle getSplitRectangle(@NotNull EditorWindow window) {
|
||||||
Rectangle getSplitRectangle(@NotNull EditorWindow window) {
|
|
||||||
final EditorComposite editorComposite = window.getSelectedComposite();
|
final EditorComposite editorComposite = window.getSelectedComposite();
|
||||||
if (editorComposite != null) {
|
if (editorComposite != null) {
|
||||||
final EditorTabbedContainer split = window.getTabbedPane();
|
final EditorTabbedContainer split = window.getTabbedPane();
|
||||||
|
@ -42,8 +42,7 @@ public class EditorHelper {
|
|||||||
// Code Vision)
|
// Code Vision)
|
||||||
private static final int BLOCK_INLAY_MAX_LINE_HEIGHT = 3;
|
private static final int BLOCK_INLAY_MAX_LINE_HEIGHT = 3;
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull Rectangle getVisibleArea(final @NotNull Editor editor) {
|
||||||
Rectangle getVisibleArea(final @NotNull Editor editor) {
|
|
||||||
return editor.getScrollingModel().getVisibleAreaOnScrollingFinished();
|
return editor.getScrollingModel().getVisibleAreaOnScrollingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ public class EditorHelper {
|
|||||||
// (either because it's too short, or it's been scrolled up)
|
// (either because it's too short, or it's been scrolled up)
|
||||||
final Rectangle visibleArea = getVisibleArea(editor);
|
final Rectangle visibleArea = getVisibleArea(editor);
|
||||||
return getFullVisualLine(editor, visibleArea.y + visibleArea.height, visibleArea.y,
|
return getFullVisualLine(editor, visibleArea.y + visibleArea.height, visibleArea.y,
|
||||||
visibleArea.y + visibleArea.height);
|
visibleArea.y + visibleArea.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getVisualLineAtBottomOfScreen(final @NotNull Editor editor) {
|
public static int getVisualLineAtBottomOfScreen(final @NotNull Editor editor) {
|
||||||
@ -156,7 +155,7 @@ public class EditorHelper {
|
|||||||
* @return The number of screen columns
|
* @return The number of screen columns
|
||||||
*/
|
*/
|
||||||
public static int getApproximateScreenWidth(final @NotNull Editor editor) {
|
public static int getApproximateScreenWidth(final @NotNull Editor editor) {
|
||||||
return (int) (getVisibleArea(editor).width / getPlainSpaceWidthFloat(editor));
|
return (int)(getVisibleArea(editor).width / getPlainSpaceWidthFloat(editor));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -195,7 +194,7 @@ public class EditorHelper {
|
|||||||
public static int getVisualColumnAtRightOfDisplay(final @NotNull Editor editor, int visualLine) {
|
public static int getVisualColumnAtRightOfDisplay(final @NotNull Editor editor, int visualLine) {
|
||||||
final Rectangle area = getVisibleArea(editor);
|
final Rectangle area = getVisibleArea(editor);
|
||||||
return getFullVisualColumn(editor, area.x + area.width - 1, editor.visualLineToY(visualLine), area.x,
|
return getFullVisualColumn(editor, area.x + area.width - 1, editor.visualLineToY(visualLine), area.x,
|
||||||
area.x + area.width);
|
area.x + area.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,8 +203,7 @@ public class EditorHelper {
|
|||||||
* @param file The virtual file get the editor for
|
* @param file The virtual file get the editor for
|
||||||
* @return The matching editor or null if no match was found
|
* @return The matching editor or null if no match was found
|
||||||
*/
|
*/
|
||||||
public static @Nullable
|
public static @Nullable Editor getEditor(final @Nullable VirtualFile file) {
|
||||||
Editor getEditor(final @Nullable VirtualFile file) {
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -222,11 +220,10 @@ public class EditorHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull String pad(final @NotNull Editor editor,
|
||||||
String pad(final @NotNull Editor editor,
|
@NotNull DataContext context,
|
||||||
@NotNull DataContext context,
|
int line,
|
||||||
int line,
|
final int to) {
|
||||||
final int to) {
|
|
||||||
final int len = EngineEditorHelperKt.lineLength(new IjVimEditor(editor), line);
|
final int len = EngineEditorHelperKt.lineLength(new IjVimEditor(editor), line);
|
||||||
if (len >= to) return "";
|
if (len >= to) return "";
|
||||||
|
|
||||||
@ -239,8 +236,7 @@ public class EditorHelper {
|
|||||||
*
|
*
|
||||||
* @param editor The editor from which the carets are taken
|
* @param editor The editor from which the carets are taken
|
||||||
*/
|
*/
|
||||||
public static @NotNull
|
public static @NotNull List<Caret> getOrderedCaretsList(@NotNull Editor editor) {
|
||||||
List<Caret> getOrderedCaretsList(@NotNull Editor editor) {
|
|
||||||
@NotNull List<Caret> carets = editor.getCaretModel().getAllCarets();
|
@NotNull List<Caret> carets = editor.getCaretModel().getAllCarets();
|
||||||
|
|
||||||
carets.sort(Comparator.comparingInt(Caret::getOffset));
|
carets.sort(Comparator.comparingInt(Caret::getOffset));
|
||||||
@ -279,7 +275,8 @@ public class EditorHelper {
|
|||||||
int inlayOffset = 0;
|
int inlayOffset = 0;
|
||||||
if (topInlayHeight > caretScreenOffset) {
|
if (topInlayHeight > caretScreenOffset) {
|
||||||
inlayOffset = topInlayHeight;
|
inlayOffset = topInlayHeight;
|
||||||
} else if (bottomInlayHeight > visibleArea.height - caretScreenOffset + editor.getLineHeight()) {
|
}
|
||||||
|
else if (bottomInlayHeight > visibleArea.height - caretScreenOffset + editor.getLineHeight()) {
|
||||||
inlayOffset = -bottomInlayHeight;
|
inlayOffset = -bottomInlayHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,7 +343,8 @@ public class EditorHelper {
|
|||||||
// screen
|
// screen
|
||||||
if (!allowVirtualSpace && offset > offsetForLastLineAtBottom) {
|
if (!allowVirtualSpace && offset > offsetForLastLineAtBottom) {
|
||||||
scrollVertically(editor, offsetForLastLineAtBottom);
|
scrollVertically(editor, offsetForLastLineAtBottom);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
scrollVertically(editor, offset);
|
scrollVertically(editor, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,7 +395,8 @@ public class EditorHelper {
|
|||||||
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
|
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
|
||||||
if (inlay != null && inlay.isRelatedToPrecedingText()) {
|
if (inlay != null && inlay.isRelatedToPrecedingText()) {
|
||||||
targetVisualColumn = visualColumn + 1;
|
targetVisualColumn = visualColumn + 1;
|
||||||
} else if (visualColumn > 0) {
|
}
|
||||||
|
else if (visualColumn > 0) {
|
||||||
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn - 1));
|
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn - 1));
|
||||||
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
|
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
|
||||||
targetVisualColumn = visualColumn - 1;
|
targetVisualColumn = visualColumn - 1;
|
||||||
@ -431,7 +430,8 @@ public class EditorHelper {
|
|||||||
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
|
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
|
||||||
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
|
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
|
||||||
targetVisualColumn = visualColumn - 1;
|
targetVisualColumn = visualColumn - 1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// If the target column is followed by an inlay which is associated with it, make the inlay the target column so
|
// If the target column is followed by an inlay which is associated with it, make the inlay the target column so
|
||||||
// it is visible
|
// it is visible
|
||||||
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn + 1));
|
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn + 1));
|
||||||
@ -449,8 +449,8 @@ public class EditorHelper {
|
|||||||
/**
|
/**
|
||||||
* Scroll page down, moving text up.
|
* Scroll page down, moving text up.
|
||||||
*
|
*
|
||||||
* @param editor The editor to scroll
|
* @param editor The editor to scroll
|
||||||
* @param pages How many pages to scroll
|
* @param pages How many pages to scroll
|
||||||
* @return A pair consisting of a flag to show if scrolling was completed, and a visual line to position the cart on
|
* @return A pair consisting of a flag to show if scrolling was completed, and a visual line to position the cart on
|
||||||
*/
|
*/
|
||||||
public static Pair<Boolean, Integer> scrollFullPageDown(final @NotNull Editor editor, int pages) {
|
public static Pair<Boolean, Integer> scrollFullPageDown(final @NotNull Editor editor, int pages) {
|
||||||
@ -471,7 +471,8 @@ public class EditorHelper {
|
|||||||
// If we're on the last page, end nicely on the last line, otherwise move the caret to the last line of the file
|
// If we're on the last page, end nicely on the last line, otherwise move the caret to the last line of the file
|
||||||
if (i == pages - 1) {
|
if (i == pages - 1) {
|
||||||
caretVisualLine = lastVisualLine;
|
caretVisualLine = lastVisualLine;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
@NotNull final VimEditor editor1 = new IjVimEditor(editor);
|
@NotNull final VimEditor editor1 = new IjVimEditor(editor);
|
||||||
caretVisualLine = EngineEditorHelperKt.getVisualLineCount(editor1) - 1;
|
caretVisualLine = EngineEditorHelperKt.getVisualLineCount(editor1) - 1;
|
||||||
completed = false;
|
completed = false;
|
||||||
@ -500,8 +501,8 @@ public class EditorHelper {
|
|||||||
/**
|
/**
|
||||||
* Scroll page up, moving text down.
|
* Scroll page up, moving text down.
|
||||||
*
|
*
|
||||||
* @param editor The editor to scroll
|
* @param editor The editor to scroll
|
||||||
* @param pages How many pages to scroll
|
* @param pages How many pages to scroll
|
||||||
* @return A pair consisting of a flag to show if scrolling was completed, and a visual line to position the cart on
|
* @return A pair consisting of a flag to show if scrolling was completed, and a visual line to position the cart on
|
||||||
*/
|
*/
|
||||||
public static Pair<Boolean, Integer> scrollFullPageUp(final @NotNull Editor editor, int pages) {
|
public static Pair<Boolean, Integer> scrollFullPageUp(final @NotNull Editor editor, int pages) {
|
||||||
@ -523,7 +524,8 @@ public class EditorHelper {
|
|||||||
if (targetBottomVisualLine == 1) {
|
if (targetBottomVisualLine == 1) {
|
||||||
completed = i == pages - 1;
|
completed = i == pages - 1;
|
||||||
break;
|
break;
|
||||||
} else if (targetBottomVisualLine == lastVisualLine) {
|
}
|
||||||
|
else if (targetBottomVisualLine == lastVisualLine) {
|
||||||
// Vim normally scrolls up window height minus two. When there are only one or two lines in the screen, due to
|
// Vim normally scrolls up window height minus two. When there are only one or two lines in the screen, due to
|
||||||
// end of file and virtual space, it scrolls window height minus one, or just plain windows height. IntelliJ
|
// end of file and virtual space, it scrolls window height minus one, or just plain windows height. IntelliJ
|
||||||
// doesn't allow us only one line when virtual space is enabled, so we only need to handle the two line case.
|
// doesn't allow us only one line when virtual space is enabled, so we only need to handle the two line case.
|
||||||
@ -549,7 +551,8 @@ public class EditorHelper {
|
|||||||
int yActual = editor.visualLineToY(line);
|
int yActual = editor.visualLineToY(line);
|
||||||
if (yActual < topBound) {
|
if (yActual < topBound) {
|
||||||
line++;
|
line++;
|
||||||
} else if (yActual + editor.getLineHeight() > bottomBound) {
|
}
|
||||||
|
else if (yActual + editor.getLineHeight() > bottomBound) {
|
||||||
line--;
|
line--;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
@ -580,7 +583,8 @@ public class EditorHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return getPreviousNonInlayVisualPosition(editor, closestVisualPosition).column;
|
return getPreviousNonInlayVisualPosition(editor, closestVisualPosition).column;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return getNextNonInlayVisualPosition(editor, closestVisualPosition).column;
|
return getNextNonInlayVisualPosition(editor, closestVisualPosition).column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,8 +617,7 @@ public class EditorHelper {
|
|||||||
* @param editor The editor
|
* @param editor The editor
|
||||||
* @return The virtual file for the editor
|
* @return The virtual file for the editor
|
||||||
*/
|
*/
|
||||||
public static @Nullable
|
public static @Nullable VirtualFile getVirtualFile(@NotNull Editor editor) {
|
||||||
VirtualFile getVirtualFile(@NotNull Editor editor) {
|
|
||||||
return FileDocumentManager.getInstance().getFile(editor.getDocument());
|
return FileDocumentManager.getInstance().getFile(editor.getDocument());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,41 +21,34 @@ import java.io.InputStreamReader;
|
|||||||
* @author vlan
|
* @author vlan
|
||||||
*/
|
*/
|
||||||
public class MacKeyRepeat {
|
public class MacKeyRepeat {
|
||||||
@VimNlsSafe
|
@VimNlsSafe public static final String FMT = "defaults %s -globalDomain ApplePressAndHoldEnabled";
|
||||||
public static final String FMT = "defaults %s -globalDomain ApplePressAndHoldEnabled";
|
@NotNull private static final MacKeyRepeat INSTANCE = new MacKeyRepeat();
|
||||||
@NotNull
|
@NonNls private static final String EXEC_COMMAND = "launchctl stop com.apple.SystemUIServer.agent";
|
||||||
private static final MacKeyRepeat INSTANCE = new MacKeyRepeat();
|
@NonNls private static final String delete = "delete";
|
||||||
@NonNls
|
@NonNls private static final String write = "write";
|
||||||
private static final String EXEC_COMMAND = "launchctl stop com.apple.SystemUIServer.agent";
|
@NonNls private static final String read = "read";
|
||||||
@NonNls
|
|
||||||
private static final String delete = "delete";
|
|
||||||
@NonNls
|
|
||||||
private static final String write = "write";
|
|
||||||
@NonNls
|
|
||||||
private static final String read = "read";
|
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull MacKeyRepeat getInstance() {
|
||||||
MacKeyRepeat getInstance() {
|
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull String read(@NotNull InputStream stream) throws IOException {
|
||||||
String read(@NotNull InputStream stream) throws IOException {
|
|
||||||
return CharStreams.toString(new InputStreamReader(stream));
|
return CharStreams.toString(new InputStreamReader(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
public @Nullable Boolean isEnabled() {
|
||||||
Boolean isEnabled() {
|
|
||||||
final String command = String.format(FMT, read);
|
final String command = String.format(FMT, read);
|
||||||
try {
|
try {
|
||||||
final Process process = Runtime.getRuntime().exec(command);
|
final Process process = Runtime.getRuntime().exec(command);
|
||||||
final String data = read(process.getInputStream()).trim();
|
final String data = read(process.getInputStream()).trim();
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(data) == 0;
|
return Integer.parseInt(data) == 0;
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +57,8 @@ public class MacKeyRepeat {
|
|||||||
final String command;
|
final String command;
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
command = String.format(FMT, delete);
|
command = String.format(FMT, delete);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final String arg = value ? "0" : "1";
|
final String arg = value ? "0" : "1";
|
||||||
command = String.format(FMT, write) + " " + arg;
|
command = String.format(FMT, write) + " " + arg;
|
||||||
}
|
}
|
||||||
@ -74,7 +68,8 @@ public class MacKeyRepeat {
|
|||||||
defaults.waitFor();
|
defaults.waitFor();
|
||||||
final Process restartSystemUI = runtime.exec(EXEC_COMMAND);
|
final Process restartSystemUI = runtime.exec(EXEC_COMMAND);
|
||||||
restartSystemUI.waitFor();
|
restartSystemUI.waitFor();
|
||||||
} catch (IOException | InterruptedException ignored) {
|
}
|
||||||
|
catch (IOException | InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,8 @@ public class PsiHelper {
|
|||||||
index = i;
|
index = i;
|
||||||
if (count > 0) count--;
|
if (count > 0) count--;
|
||||||
break;
|
break;
|
||||||
} else if (navigationOffsets.get(i) == offset) {
|
}
|
||||||
|
else if (navigationOffsets.get(i) == offset) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -69,7 +70,8 @@ public class PsiHelper {
|
|||||||
int resultIndex = index + count;
|
int resultIndex = index + count;
|
||||||
if (resultIndex < 0) {
|
if (resultIndex < 0) {
|
||||||
resultIndex = 0;
|
resultIndex = 0;
|
||||||
} else if (resultIndex >= navigationOffsets.size()) {
|
}
|
||||||
|
else if (resultIndex >= navigationOffsets.size()) {
|
||||||
resultIndex = navigationOffsets.size() - 1;
|
resultIndex = navigationOffsets.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ public class PsiHelper {
|
|||||||
@NotNull List<Integer> navigationOffsets,
|
@NotNull List<Integer> navigationOffsets,
|
||||||
boolean start) {
|
boolean start) {
|
||||||
if (root instanceof PsiTreeElementBase) {
|
if (root instanceof PsiTreeElementBase) {
|
||||||
PsiElement element = ((PsiTreeElementBase<?>) root).getValue();
|
PsiElement element = ((PsiTreeElementBase<?>)root).getValue();
|
||||||
int offset;
|
int offset;
|
||||||
if (start) {
|
if (start) {
|
||||||
offset = element.getTextRange().getStartOffset();
|
offset = element.getTextRange().getStartOffset();
|
||||||
@ -93,7 +95,8 @@ public class PsiHelper {
|
|||||||
offset += braceIndex;
|
offset += braceIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
offset = element.getTextRange().getEndOffset() - 1;
|
offset = element.getTextRange().getEndOffset() - 1;
|
||||||
}
|
}
|
||||||
if (!navigationOffsets.contains(offset)) {
|
if (!navigationOffsets.contains(offset)) {
|
||||||
@ -105,8 +108,7 @@ public class PsiHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @Nullable
|
public static @Nullable PsiFile getFile(@NotNull Editor editor) {
|
||||||
PsiFile getFile(@NotNull Editor editor) {
|
|
||||||
VirtualFile vf = EditorHelper.getVirtualFile(editor);
|
VirtualFile vf = EditorHelper.getVirtualFile(editor);
|
||||||
if (vf != null) {
|
if (vf != null) {
|
||||||
Project proj = editor.getProject();
|
Project proj = editor.getProject();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -79,11 +79,9 @@ internal var Caret.vimLastColumn: Int
|
|||||||
_vimLastColumn = value
|
_vimLastColumn = value
|
||||||
_vimLastColumnPos = visualPosition
|
_vimLastColumnPos = visualPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Caret.resetVimLastColumn() {
|
internal fun Caret.resetVimLastColumn() {
|
||||||
_vimLastColumnPos = null
|
_vimLastColumnPos = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private var Caret._vimLastColumn: Int by userDataCaretToEditorOr { (this as Caret).inlayAwareVisualColumn }
|
private var Caret._vimLastColumn: Int by userDataCaretToEditorOr { (this as Caret).inlayAwareVisualColumn }
|
||||||
private var Caret._vimLastColumnPos: VisualPosition? by userDataCaretToEditor()
|
private var Caret._vimLastColumnPos: VisualPosition? by userDataCaretToEditor()
|
||||||
|
|
||||||
|
@ -15,17 +15,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public final class VimIcons {
|
public final class VimIcons {
|
||||||
public static final @NotNull
|
public static final @NotNull Icon IDEAVIM = load("/icons/ideavim.svg");
|
||||||
Icon IDEAVIM = load("/icons/ideavim.svg");
|
public static final @NotNull Icon IDEAVIM_DISABLED = load("/icons/ideavim_disabled.svg");
|
||||||
public static final @NotNull
|
public static final @NotNull Icon TWITTER = load("/icons/twitter.svg");
|
||||||
Icon IDEAVIM_DISABLED = load("/icons/ideavim_disabled.svg");
|
public static final @NotNull Icon YOUTRACK = load("/icons/youtrack.svg");
|
||||||
public static final @NotNull
|
|
||||||
Icon TWITTER = load("/icons/twitter.svg");
|
|
||||||
public static final @NotNull
|
|
||||||
Icon YOUTRACK = load("/icons/youtrack.svg");
|
|
||||||
|
|
||||||
private static @NotNull
|
private static @NotNull Icon load(@NotNull @NonNls String path) {
|
||||||
Icon load(@NotNull @NonNls String path) {
|
|
||||||
return IconManager.getInstance().getIcon(path, VimIcons.class);
|
return IconManager.getInstance().getIcon(path, VimIcons.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,7 @@ internal object IdeaSpecifics {
|
|||||||
val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction
|
val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction
|
||||||
if (!isVimAction && injector.globalOptions().isSet(IjOptionConstants.trackactionids)) {
|
if (!isVimAction && injector.globalOptions().isSet(IjOptionConstants.trackactionids)) {
|
||||||
if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) {
|
if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) {
|
||||||
val id: String? = ActionManager.getInstance().getId(action)
|
val id: String? = ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
|
||||||
?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
|
|
||||||
VimPlugin.getNotifications(event.dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
|
VimPlugin.getNotifications(event.dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ internal class IntellijMark(bookmark: LineBookmark, override val col: Int, proje
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getMark(): LineBookmark? =
|
private fun getMark(): LineBookmark? =
|
||||||
getProject()?.let { project ->
|
getProject()?.let {
|
||||||
|
project ->
|
||||||
BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
|
BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ internal class IjVimCaret(val caret: Caret) : VimCaretBase() {
|
|||||||
set(value) {
|
set(value) {
|
||||||
caret.vimLastColumn = value
|
caret.vimLastColumn = value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun resetLastColumn() = caret.resetVimLastColumn()
|
override fun resetLastColumn() = caret.resetVimLastColumn()
|
||||||
override val selectionStart: Int
|
override val selectionStart: Int
|
||||||
get() = caret.selectionStart
|
get() = caret.selectionStart
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* IdeaVim command index.
|
* IdeaVim command index.
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 1. Insert mode
|
* 1. Insert mode
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |i_CTRL-@| {@link com.maddyhome.idea.vim.action.change.insert.InsertPreviousInsertExitAction}
|
* |i_CTRL-@| {@link com.maddyhome.idea.vim.action.change.insert.InsertPreviousInsertExitAction}
|
||||||
* |i_CTRL-A| {@link com.maddyhome.idea.vim.action.change.insert.InsertPreviousInsertAction}
|
* |i_CTRL-A| {@link com.maddyhome.idea.vim.action.change.insert.InsertPreviousInsertAction}
|
||||||
* |i_CTRL-C| {@link com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction}
|
* |i_CTRL-C| {@link com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction}
|
||||||
@ -80,13 +80,13 @@
|
|||||||
* |i_<F1>| IntelliJ help
|
* |i_<F1>| IntelliJ help
|
||||||
* |i_<Insert>| IntelliJ editor toggle insert/replace
|
* |i_<Insert>| IntelliJ editor toggle insert/replace
|
||||||
* |i_CTRL-X_index| TO BE IMPLEMENTED
|
* |i_CTRL-X_index| TO BE IMPLEMENTED
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2. Normal mode
|
* 2. Normal mode
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |CTRL-A| {@link com.maddyhome.idea.vim.action.change.change.number.ChangeNumberIncAction}
|
* |CTRL-A| {@link com.maddyhome.idea.vim.action.change.change.number.ChangeNumberIncAction}
|
||||||
* |CTRL-B| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollPageUpAction}
|
* |CTRL-B| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollPageUpAction}
|
||||||
* |CTRL-C| TO BE IMPLEMENTED
|
* |CTRL-C| TO BE IMPLEMENTED
|
||||||
@ -241,18 +241,18 @@
|
|||||||
* |<S-Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftHomeAction}
|
* |<S-Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftHomeAction}
|
||||||
* |<S-End>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftEndAction}
|
* |<S-End>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftEndAction}
|
||||||
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
|
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2.1. Text objects
|
* 2.1. Text objects
|
||||||
* <p>
|
*
|
||||||
* Text object commands are listed in the visual mode section.
|
* Text object commands are listed in the visual mode section.
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2.2. Window commands
|
* 2.2. Window commands
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |CTRL-W_+| TO BE IMPLEMENTED
|
* |CTRL-W_+| TO BE IMPLEMENTED
|
||||||
* |CTRL-W_-| TO BE IMPLEMENTED
|
* |CTRL-W_-| TO BE IMPLEMENTED
|
||||||
* |CTRL-W_<| TO BE IMPLEMENTED
|
* |CTRL-W_<| TO BE IMPLEMENTED
|
||||||
@ -305,10 +305,10 @@
|
|||||||
* |CTRL-W_CTRL-J| {@link com.maddyhome.idea.vim.action.window.WindowDownAction}
|
* |CTRL-W_CTRL-J| {@link com.maddyhome.idea.vim.action.window.WindowDownAction}
|
||||||
* |CTRL-W_CTRL-K| {@link com.maddyhome.idea.vim.action.window.WindowUpAction}
|
* |CTRL-W_CTRL-K| {@link com.maddyhome.idea.vim.action.window.WindowUpAction}
|
||||||
* |CTRL-W_CTRL-L| {@link com.maddyhome.idea.vim.action.window.WindowRightAction}
|
* |CTRL-W_CTRL-L| {@link com.maddyhome.idea.vim.action.window.WindowRightAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2.3. Square bracket commands
|
* 2.3. Square bracket commands
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* |[_CTRL-D| TO BE IMPLEMENTED
|
* |[_CTRL-D| TO BE IMPLEMENTED
|
||||||
@ -361,13 +361,13 @@
|
|||||||
* |]s| TO BE IMPLEMENTED
|
* |]s| TO BE IMPLEMENTED
|
||||||
* |]z| TO BE IMPLEMENTED
|
* |]z| TO BE IMPLEMENTED
|
||||||
* |]}| {@link com.maddyhome.idea.vim.action.motion.text.MotionUnmatchedBraceCloseAction}
|
* |]}| {@link com.maddyhome.idea.vim.action.motion.text.MotionUnmatchedBraceCloseAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2.4. Commands starting with 'g'
|
* 2.4. Commands starting with 'g'
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |g_CTRL-A| not applicable
|
* |g_CTRL-A| not applicable
|
||||||
* |g_CTRL-G| {@link com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction}
|
* |g_CTRL-G| {@link com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction}
|
||||||
* |g_CTRL-H| {@link com.maddyhome.idea.vim.action.motion.select.SelectEnableBlockModeAction}
|
* |g_CTRL-H| {@link com.maddyhome.idea.vim.action.motion.select.SelectEnableBlockModeAction}
|
||||||
@ -434,10 +434,10 @@
|
|||||||
* |g<End>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionLastScreenColumnAction}
|
* |g<End>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionLastScreenColumnAction}
|
||||||
* |g<Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionFirstScreenColumnAction}
|
* |g<Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionFirstScreenColumnAction}
|
||||||
* |g<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionUpNotLineWiseAction}
|
* |g<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionUpNotLineWiseAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 2.5. Commands starting with 'z'
|
* 2.5. Commands starting with 'z'
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* |z<CR>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollFirstScreenLineStartAction}
|
* |z<CR>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollFirstScreenLineStartAction}
|
||||||
@ -484,13 +484,13 @@
|
|||||||
* |zz| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollMiddleScreenLineAction}
|
* |zz| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollMiddleScreenLineAction}
|
||||||
* |z<Left>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnRightAction}
|
* |z<Left>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnRightAction}
|
||||||
* |z<Right>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnLeftAction}
|
* |z<Right>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnLeftAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 3. Visual mode
|
* 3. Visual mode
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |v_CTRL-\_CTRL-N| {@link com.maddyhome.idea.vim.action.motion.visual.VisualExitModeAction}
|
* |v_CTRL-\_CTRL-N| {@link com.maddyhome.idea.vim.action.motion.visual.VisualExitModeAction}
|
||||||
* |v_CTRL-\_CTRL-G| TO BE IMPLEMENTED
|
* |v_CTRL-\_CTRL-G| TO BE IMPLEMENTED
|
||||||
* |v_CTRL-A| {@link com.maddyhome.idea.vim.action.change.change.number.ChangeVisualNumberIncAction}
|
* |v_CTRL-A| {@link com.maddyhome.idea.vim.action.change.change.number.ChangeVisualNumberIncAction}
|
||||||
@ -578,10 +578,10 @@
|
|||||||
* |v_~| {@link com.maddyhome.idea.vim.action.change.change.ChangeCaseToggleVisualAction}
|
* |v_~| {@link com.maddyhome.idea.vim.action.change.change.ChangeCaseToggleVisualAction}
|
||||||
* |v_`| {@link com.maddyhome.idea.vim.action.motion.mark.MotionGotoFileMarkAction}
|
* |v_`| {@link com.maddyhome.idea.vim.action.motion.mark.MotionGotoFileMarkAction}
|
||||||
* |v_'| {@link com.maddyhome.idea.vim.action.motion.mark.MotionGotoFileMarkLineAction}
|
* |v_'| {@link com.maddyhome.idea.vim.action.motion.mark.MotionGotoFileMarkLineAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 4. Select mode
|
* 4. Select mode
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* |<BS>| {@link com.maddyhome.idea.vim.action.motion.select.SelectDeleteAction}
|
* |<BS>| {@link com.maddyhome.idea.vim.action.motion.select.SelectDeleteAction}
|
||||||
@ -597,12 +597,12 @@
|
|||||||
* |<Left>| {@link com.maddyhome.idea.vim.action.motion.select.motion.SelectMotionLeftAction}
|
* |<Left>| {@link com.maddyhome.idea.vim.action.motion.select.motion.SelectMotionLeftAction}
|
||||||
* |<Right>| {@link com.maddyhome.idea.vim.action.motion.select.motion.SelectMotionRightAction}
|
* |<Right>| {@link com.maddyhome.idea.vim.action.motion.select.motion.SelectMotionRightAction}
|
||||||
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
|
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
|
||||||
* <p>
|
*
|
||||||
* 5. Command line editing
|
* 5. Command line editing
|
||||||
* <p>
|
*
|
||||||
* tag action
|
* tag action
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |c_CTRL-A| TO BE IMPLEMENTED
|
* |c_CTRL-A| TO BE IMPLEMENTED
|
||||||
* |c_CTRL-B| {@link javax.swing.text.DefaultEditorKit#beginLineAction}
|
* |c_CTRL-B| {@link javax.swing.text.DefaultEditorKit#beginLineAction}
|
||||||
* |c_CTRL-C| {@link com.maddyhome.idea.vim.ui.ex.CancelEntryAction}
|
* |c_CTRL-C| {@link com.maddyhome.idea.vim.ui.ex.CancelEntryAction}
|
||||||
@ -665,13 +665,13 @@
|
|||||||
* |c_digraph| {char1} <BS> {char2}
|
* |c_digraph| {char1} <BS> {char2}
|
||||||
* |c_wildchar| TO BE IMPLEMENTED
|
* |c_wildchar| TO BE IMPLEMENTED
|
||||||
* |'cedit'| TO BE IMPLEMENTED
|
* |'cedit'| TO BE IMPLEMENTED
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* 6. Ex commands
|
* 6. Ex commands
|
||||||
* <p>
|
*
|
||||||
* tag handler
|
* tag handler
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* <p>
|
*
|
||||||
* |:map| {@link com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand}
|
* |:map| {@link com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand}
|
||||||
* |:nmap| ...
|
* |:nmap| ...
|
||||||
* |:vmap| ...
|
* |:vmap| ...
|
||||||
@ -696,12 +696,12 @@
|
|||||||
* |:delcommand| {@link com.maddyhome.idea.vim.vimscript.model.commands.DelCmdCommand}
|
* |:delcommand| {@link com.maddyhome.idea.vim.vimscript.model.commands.DelCmdCommand}
|
||||||
* |:comclear| {@link com.maddyhome.idea.vim.vimscript.model.commands.CmdClearCommand}
|
* |:comclear| {@link com.maddyhome.idea.vim.vimscript.model.commands.CmdClearCommand}
|
||||||
* ...
|
* ...
|
||||||
* <p>
|
*
|
||||||
* The list of supported Ex commands is incomplete.
|
* The list of supported Ex commands is incomplete.
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* A. Misc commands
|
* A. Misc commands
|
||||||
* <p>
|
*
|
||||||
* tag handler
|
* tag handler
|
||||||
* -------------------------------------------------------------------------------------------------------------------
|
* -------------------------------------------------------------------------------------------------------------------
|
||||||
* |]b| {@link com.maddyhome.idea.vim.action.motion.text.MotionCamelEndLeftAction}
|
* |]b| {@link com.maddyhome.idea.vim.action.motion.text.MotionCamelEndLeftAction}
|
||||||
@ -710,8 +710,8 @@
|
|||||||
* |[w| {@link com.maddyhome.idea.vim.action.motion.text.MotionCamelRightAction}
|
* |[w| {@link com.maddyhome.idea.vim.action.motion.text.MotionCamelRightAction}
|
||||||
* |g(| {@link com.maddyhome.idea.vim.action.motion.text.MotionSentencePreviousEndAction}
|
* |g(| {@link com.maddyhome.idea.vim.action.motion.text.MotionSentencePreviousEndAction}
|
||||||
* |g)| {@link com.maddyhome.idea.vim.action.motion.text.MotionSentenceNextEndAction}
|
* |g)| {@link com.maddyhome.idea.vim.action.motion.text.MotionSentenceNextEndAction}
|
||||||
* <p>
|
*
|
||||||
* <p>
|
*
|
||||||
* See also :help index.
|
* See also :help index.
|
||||||
*
|
*
|
||||||
* @author vlan
|
* @author vlan
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -39,8 +39,7 @@ internal class ShortcutConflictState : ApplicationUsagesCollector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getHandlersForShortcut(shortcut: KeyStroke): List<HandledModes> {
|
private fun getHandlersForShortcut(shortcut: KeyStroke): List<HandledModes> {
|
||||||
val modes = VimPlugin.getKey().shortcutConflicts[shortcut]
|
val modes = VimPlugin.getKey().shortcutConflicts[shortcut] ?: return listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED)
|
||||||
?: return listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED)
|
|
||||||
|
|
||||||
return when (modes) {
|
return when (modes) {
|
||||||
is ShortcutOwnerInfo.AllModes -> {
|
is ShortcutOwnerInfo.AllModes -> {
|
||||||
|
@ -23,8 +23,7 @@ internal class VimscriptState : ApplicationUsagesCollector() {
|
|||||||
return setOf(
|
return setOf(
|
||||||
VIMSCRIPT.metric(
|
VIMSCRIPT.metric(
|
||||||
SOURCED_FILES with sourcedFiles.size,
|
SOURCED_FILES with sourcedFiles.size,
|
||||||
IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size
|
IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size ?: -1),
|
||||||
?: -1),
|
|
||||||
EXTENSIONS_ENABLED_BY_SET with (PluginState.enabledExtensions - extensionsEnabledWithPlug).toList(),
|
EXTENSIONS_ENABLED_BY_SET with (PluginState.enabledExtensions - extensionsEnabledWithPlug).toList(),
|
||||||
EXTENSIONS_ENABLED_BY_PLUG with extensionsEnabledWithPlug.toList(),
|
EXTENSIONS_ENABLED_BY_PLUG with extensionsEnabledWithPlug.toList(),
|
||||||
IS_IDE_SPECIFIC_CONFIGURATION_USED with isIDESpecificConfigurationUsed,
|
IS_IDE_SPECIFIC_CONFIGURATION_USED with isIDESpecificConfigurationUsed,
|
||||||
|
@ -44,25 +44,18 @@ import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
|
|||||||
* This panel displays text in a <code>more</code> like window.
|
* This panel displays text in a <code>more</code> like window.
|
||||||
*/
|
*/
|
||||||
public class ExOutputPanel extends JPanel {
|
public class ExOutputPanel extends JPanel {
|
||||||
private final @NotNull
|
private final @NotNull Editor myEditor;
|
||||||
Editor myEditor;
|
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull JLabel myLabel = new JLabel("more");
|
||||||
JLabel myLabel = new JLabel("more");
|
private final @NotNull JTextArea myText = new JTextArea();
|
||||||
private final @NotNull
|
private final @NotNull JScrollPane myScrollPane =
|
||||||
JTextArea myText = new JTextArea();
|
|
||||||
private final @NotNull
|
|
||||||
JScrollPane myScrollPane =
|
|
||||||
new JBScrollPane(myText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
new JBScrollPane(myText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
private final @NotNull
|
private final @NotNull ComponentAdapter myAdapter;
|
||||||
ComponentAdapter myAdapter;
|
|
||||||
private boolean myAtEnd = false;
|
private boolean myAtEnd = false;
|
||||||
private int myLineHeight = 0;
|
private int myLineHeight = 0;
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable JComponent myOldGlass = null;
|
||||||
JComponent myOldGlass = null;
|
private @Nullable LayoutManager myOldLayout = null;
|
||||||
private @Nullable
|
|
||||||
LayoutManager myOldLayout = null;
|
|
||||||
private boolean myWasOpaque = false;
|
private boolean myWasOpaque = false;
|
||||||
|
|
||||||
private boolean myActive = false;
|
private boolean myActive = false;
|
||||||
@ -97,8 +90,7 @@ public class ExOutputPanel extends JPanel {
|
|||||||
return UserDataManager.getVimMorePanel(editor) != null;
|
return UserDataManager.getVimMorePanel(editor) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @NotNull
|
public static @NotNull ExOutputPanel getInstance(@NotNull Editor editor) {
|
||||||
ExOutputPanel getInstance(@NotNull Editor editor) {
|
|
||||||
ExOutputPanel panel = UserDataManager.getVimMorePanel(editor);
|
ExOutputPanel panel = UserDataManager.getVimMorePanel(editor);
|
||||||
if (panel == null) {
|
if (panel == null) {
|
||||||
panel = new ExOutputPanel(editor);
|
panel = new ExOutputPanel(editor);
|
||||||
@ -191,7 +183,7 @@ public class ExOutputPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
private void activate() {
|
private void activate() {
|
||||||
JRootPane root = SwingUtilities.getRootPane(myEditor.getContentComponent());
|
JRootPane root = SwingUtilities.getRootPane(myEditor.getContentComponent());
|
||||||
myOldGlass = (JComponent) root.getGlassPane();
|
myOldGlass = (JComponent)root.getGlassPane();
|
||||||
if (myOldGlass != null) {
|
if (myOldGlass != null) {
|
||||||
myOldLayout = myOldGlass.getLayout();
|
myOldLayout = myOldGlass.getLayout();
|
||||||
myWasOpaque = myOldGlass.isOpaque();
|
myWasOpaque = myOldGlass.isOpaque();
|
||||||
@ -228,13 +220,14 @@ public class ExOutputPanel extends JPanel {
|
|||||||
private void scrollHalfPage() {
|
private void scrollHalfPage() {
|
||||||
double sa = myScrollPane.getVerticalScrollBar().getVisibleAmount() / 2.0;
|
double sa = myScrollPane.getVerticalScrollBar().getVisibleAmount() / 2.0;
|
||||||
double offset = Math.ceil(sa / myLineHeight) * myLineHeight;
|
double offset = Math.ceil(sa / myLineHeight) * myLineHeight;
|
||||||
scrollOffset((int) offset);
|
scrollOffset((int)offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleEnter() {
|
private void handleEnter() {
|
||||||
if (myAtEnd) {
|
if (myAtEnd) {
|
||||||
close();
|
close();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
scrollLine();
|
scrollLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,10 +243,11 @@ public class ExOutputPanel extends JPanel {
|
|||||||
myScrollPane.getVerticalScrollBar().setValue(val + more);
|
myScrollPane.getVerticalScrollBar().setValue(val + more);
|
||||||
myScrollPane.getHorizontalScrollBar().setValue(0);
|
myScrollPane.getHorizontalScrollBar().setValue(0);
|
||||||
if (val + more >=
|
if (val + more >=
|
||||||
myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount()) {
|
myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount()) {
|
||||||
myAtEnd = true;
|
myAtEnd = true;
|
||||||
myLabel.setText(MessageHelper.message("hit.enter.or.type.command.to.continue"));
|
myLabel.setText(MessageHelper.message("hit.enter.or.type.command.to.continue"));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
myLabel.setText(MessageHelper.message("ex.output.panel.more"));
|
myLabel.setText(MessageHelper.message("ex.output.panel.more"));
|
||||||
}
|
}
|
||||||
myLabel.setFont(UiHelper.selectFont(myLabel.getText()));
|
myLabel.setFont(UiHelper.selectFont(myLabel.getText()));
|
||||||
@ -269,14 +263,14 @@ public class ExOutputPanel extends JPanel {
|
|||||||
int visLines = getSize().height / myLineHeight - 1;
|
int visLines = getSize().height / myLineHeight - 1;
|
||||||
int lines = Math.min(count, visLines);
|
int lines = Math.min(count, visLines);
|
||||||
setSize(getSize().width,
|
setSize(getSize().width,
|
||||||
lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2);
|
lines * myLineHeight + myLabel.getPreferredSize().height + getBorder().getBorderInsets(this).top * 2);
|
||||||
|
|
||||||
int height = getSize().height;
|
int height = getSize().height;
|
||||||
Rectangle bounds = scroll.getBounds();
|
Rectangle bounds = scroll.getBounds();
|
||||||
bounds.translate(0, scroll.getHeight() - height);
|
bounds.translate(0, scroll.getHeight() - height);
|
||||||
bounds.height = height;
|
bounds.height = height;
|
||||||
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
|
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
|
||||||
SwingUtilities.getRootPane(contentComponent).getGlassPane());
|
SwingUtilities.getRootPane(contentComponent).getGlassPane());
|
||||||
bounds.setLocation(pos);
|
bounds.setLocation(pos);
|
||||||
setBounds(bounds);
|
setBounds(bounds);
|
||||||
|
|
||||||
@ -284,7 +278,8 @@ public class ExOutputPanel extends JPanel {
|
|||||||
if (!globalOptions(injector).isSet(OptionConstants.more)) {
|
if (!globalOptions(injector).isSet(OptionConstants.more)) {
|
||||||
// FIX
|
// FIX
|
||||||
scrollOffset(100000);
|
scrollOffset(100000);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
scrollOffset(0);
|
scrollOffset(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,7 +319,8 @@ public class ExOutputPanel extends JPanel {
|
|||||||
public void keyTyped(@NotNull KeyEvent e) {
|
public void keyTyped(@NotNull KeyEvent e) {
|
||||||
if (myExOutputPanel.myAtEnd) {
|
if (myExOutputPanel.myAtEnd) {
|
||||||
myExOutputPanel.close(e);
|
myExOutputPanel.close(e);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
switch (e.getKeyChar()) {
|
switch (e.getKeyChar()) {
|
||||||
case ' ':
|
case ' ':
|
||||||
myExOutputPanel.scrollPage();
|
myExOutputPanel.scrollPage();
|
||||||
|
@ -89,7 +89,7 @@ public class ExDocument extends PlainDocument {
|
|||||||
if (attribute instanceof AttributedString as) {
|
if (attribute instanceof AttributedString as) {
|
||||||
final Map<AttributedCharacterIterator.Attribute, Object> attributes = as.getIterator().getAttributes();
|
final Map<AttributedCharacterIterator.Attribute, Object> attributes = as.getIterator().getAttributes();
|
||||||
if (!attributes.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT) &&
|
if (!attributes.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT) &&
|
||||||
!attributes.containsKey(TextAttribute.INPUT_METHOD_UNDERLINE)) {
|
!attributes.containsKey(TextAttribute.INPUT_METHOD_UNDERLINE)) {
|
||||||
as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT, InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT);
|
as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT, InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class ExEntryPanel extends JPanel {
|
|||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
JRootPane root = SwingUtilities.getRootPane(parent);
|
JRootPane root = SwingUtilities.getRootPane(parent);
|
||||||
if (root == null) return;
|
if (root == null) return;
|
||||||
oldGlass = (JComponent) root.getGlassPane();
|
oldGlass = (JComponent)root.getGlassPane();
|
||||||
oldLayout = oldGlass.getLayout();
|
oldLayout = oldGlass.getLayout();
|
||||||
wasOpaque = oldGlass.isOpaque();
|
wasOpaque = oldGlass.isOpaque();
|
||||||
oldGlass.setLayout(null);
|
oldGlass.setLayout(null);
|
||||||
@ -203,7 +203,8 @@ public class ExEntryPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry.deactivate();
|
entry.deactivate();
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
|
|
||||||
// Make sure we hide the UI, especially if something goes wrong
|
// Make sure we hide the UI, especially if something goes wrong
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
@ -235,13 +236,12 @@ public class ExEntryPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
final ScrollingModel scrollingModel = editor.getScrollingModel();
|
final ScrollingModel scrollingModel = editor.getScrollingModel();
|
||||||
if (scrollingModel.getHorizontalScrollOffset() != horizontalOffset ||
|
if (scrollingModel.getHorizontalScrollOffset() != horizontalOffset ||
|
||||||
scrollingModel.getVerticalScrollOffset() != verticalOffset) {
|
scrollingModel.getVerticalScrollOffset() != verticalOffset) {
|
||||||
scrollingModel.scroll(horizontalOffset, verticalOffset);
|
scrollingModel.scroll(horizontalOffset, verticalOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull DocumentListener fontListener = new DocumentAdapter() {
|
||||||
DocumentListener fontListener = new DocumentAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
protected void textChanged(@NotNull DocumentEvent e) {
|
protected void textChanged(@NotNull DocumentEvent e) {
|
||||||
String text = entry.getActualText();
|
String text = entry.getActualText();
|
||||||
@ -252,8 +252,7 @@ public class ExEntryPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull DocumentListener incSearchDocumentListener = new DocumentAdapter() {
|
||||||
DocumentListener incSearchDocumentListener = new DocumentAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
protected void textChanged(@NotNull DocumentEvent e) {
|
protected void textChanged(@NotNull DocumentEvent e) {
|
||||||
final Editor editor = entry.getEditor();
|
final Editor editor = entry.getEditor();
|
||||||
@ -297,15 +296,15 @@ public class ExEntryPanel extends JPanel {
|
|||||||
final int matchOffset = SearchHighlightsHelper.updateIncsearchHighlights(editor, pattern, forwards, caretOffset, searchRange);
|
final int matchOffset = SearchHighlightsHelper.updateIncsearchHighlights(editor, pattern, forwards, caretOffset, searchRange);
|
||||||
if (matchOffset != -1) {
|
if (matchOffset != -1) {
|
||||||
new IjVimCaret(editor.getCaretModel().getPrimaryCaret()).moveToOffset(matchOffset);
|
new IjVimCaret(editor.getCaretModel().getPrimaryCaret()).moveToOffset(matchOffset);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
resetCaretOffset(editor);
|
resetCaretOffset(editor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("null -> null")
|
@Contract("null -> null")
|
||||||
private @Nullable
|
private @Nullable Command getIncsearchCommand(@Nullable String commandText) {
|
||||||
Command getIncsearchCommand(@Nullable String commandText) {
|
|
||||||
if (commandText == null) return null;
|
if (commandText == null) return null;
|
||||||
try {
|
try {
|
||||||
final Command exCommand = VimscriptParser.INSTANCE.parseCommand(commandText);
|
final Command exCommand = VimscriptParser.INSTANCE.parseCommand(commandText);
|
||||||
@ -313,7 +312,8 @@ public class ExEntryPanel extends JPanel {
|
|||||||
if (exCommand instanceof SubstituteCommand) {
|
if (exCommand instanceof SubstituteCommand) {
|
||||||
return exCommand;
|
return exCommand;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch(Exception e) {
|
||||||
logger.warn("Cannot parse command for incsearch", e);
|
logger.warn("Cannot parse command for incsearch", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,13 +353,11 @@ public class ExEntryPanel extends JPanel {
|
|||||||
*
|
*
|
||||||
* @return The user entered text
|
* @return The user entered text
|
||||||
*/
|
*/
|
||||||
public @NotNull
|
public @NotNull String getText() {
|
||||||
String getText() {
|
|
||||||
return entry.getActualText();
|
return entry.getActualText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull
|
public @NotNull ExTextField getEntry() {
|
||||||
ExTextField getEntry() {
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +410,7 @@ public class ExEntryPanel extends JPanel {
|
|||||||
if (parent == null) return;
|
if (parent == null) return;
|
||||||
|
|
||||||
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
|
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
|
||||||
int height = (int) getPreferredSize().getHeight();
|
int height = (int)getPreferredSize().getHeight();
|
||||||
if (scroll != null) {
|
if (scroll != null) {
|
||||||
Rectangle bounds = scroll.getBounds();
|
Rectangle bounds = scroll.getBounds();
|
||||||
bounds.translate(0, scroll.getHeight() - height);
|
bounds.translate(0, scroll.getHeight() - height);
|
||||||
@ -432,12 +430,9 @@ public class ExEntryPanel extends JPanel {
|
|||||||
private int count;
|
private int count;
|
||||||
|
|
||||||
// UI stuff
|
// UI stuff
|
||||||
private @Nullable
|
private @Nullable JComponent parent;
|
||||||
JComponent parent;
|
private final @NotNull JLabel label;
|
||||||
private final @NotNull
|
private final @NotNull ExTextField entry;
|
||||||
JLabel label;
|
|
||||||
private final @NotNull
|
|
||||||
ExTextField entry;
|
|
||||||
private JComponent oldGlass;
|
private JComponent oldGlass;
|
||||||
private LayoutManager oldLayout;
|
private LayoutManager oldLayout;
|
||||||
private boolean wasOpaque;
|
private boolean wasOpaque;
|
||||||
@ -447,8 +442,7 @@ public class ExEntryPanel extends JPanel {
|
|||||||
private int horizontalOffset;
|
private int horizontalOffset;
|
||||||
private int caretOffset;
|
private int caretOffset;
|
||||||
|
|
||||||
private final @NotNull
|
private final @NotNull ComponentListener resizePanelListener = new ComponentAdapter() {
|
||||||
ComponentListener resizePanelListener = new ComponentAdapter() {
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
positionPanel();
|
positionPanel();
|
||||||
|
@ -47,8 +47,7 @@ import static java.lang.Math.*;
|
|||||||
*/
|
*/
|
||||||
public class ExTextField extends JTextField {
|
public class ExTextField extends JTextField {
|
||||||
|
|
||||||
public static final @NonNls
|
public static final @NonNls String KEYMAP_NAME = "ex";
|
||||||
String KEYMAP_NAME = "ex";
|
|
||||||
|
|
||||||
public boolean useHandleKeyFromEx = true;
|
public boolean useHandleKeyFromEx = true;
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ public class ExTextField extends JTextField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the current text for use in filtering history. Required for scrolling through multiple history entries
|
* Stores the current text for use in filtering history. Required for scrolling through multiple history entries
|
||||||
* <p>
|
*
|
||||||
* Called whenever the text is changed, either by typing, or by special characters altering the text (e.g. Delete)
|
* Called whenever the text is changed, either by typing, or by special characters altering the text (e.g. Delete)
|
||||||
*/
|
*/
|
||||||
void saveLastEntry() {
|
void saveLastEntry() {
|
||||||
@ -162,7 +161,8 @@ public class ExTextField extends JTextField {
|
|||||||
String txt;
|
String txt;
|
||||||
if (i == history.size()) {
|
if (i == history.size()) {
|
||||||
txt = lastEntry;
|
txt = lastEntry;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
HistoryEntry entry = history.get(i);
|
HistoryEntry entry = history.get(i);
|
||||||
txt = entry.getEntry();
|
txt = entry.getEntry();
|
||||||
}
|
}
|
||||||
@ -176,12 +176,14 @@ public class ExTextField extends JTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VimPlugin.indicateError();
|
VimPlugin.indicateError();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
histIndex += dir;
|
histIndex += dir;
|
||||||
String txt;
|
String txt;
|
||||||
if (histIndex == history.size()) {
|
if (histIndex == history.size()) {
|
||||||
txt = lastEntry;
|
txt = lastEntry;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
HistoryEntry entry = history.get(histIndex);
|
HistoryEntry entry = history.get(histIndex);
|
||||||
txt = entry.getEntry();
|
txt = entry.getEntry();
|
||||||
}
|
}
|
||||||
@ -254,7 +256,8 @@ public class ExTextField extends JTextField {
|
|||||||
// dispatch to ExEntryPanel#handleKey and if it's processed, mark the event as consumed.
|
// dispatch to ExEntryPanel#handleKey and if it's processed, mark the event as consumed.
|
||||||
if (currentAction != null) {
|
if (currentAction != null) {
|
||||||
currentAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, String.valueOf(c), modifiers));
|
currentAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, String.valueOf(c), modifiers));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
KeyEvent event = new KeyEvent(this, keyChar != KeyEvent.CHAR_UNDEFINED ? KeyEvent.KEY_TYPED :
|
KeyEvent event = new KeyEvent(this, keyChar != KeyEvent.CHAR_UNDEFINED ? KeyEvent.KEY_TYPED :
|
||||||
(stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED),
|
(stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED),
|
||||||
(new Date()).getTime(), modifiers, keyCode, c);
|
(new Date()).getTime(), modifiers, keyCode, c);
|
||||||
@ -262,7 +265,7 @@ public class ExTextField extends JTextField {
|
|||||||
useHandleKeyFromEx = false;
|
useHandleKeyFromEx = false;
|
||||||
try {
|
try {
|
||||||
super.processKeyEvent(event);
|
super.processKeyEvent(event);
|
||||||
} finally {
|
}finally {
|
||||||
useHandleKeyFromEx = true;
|
useHandleKeyFromEx = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,8 +285,7 @@ public class ExTextField extends JTextField {
|
|||||||
* @return the default model implementation
|
* @return the default model implementation
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected @NotNull
|
protected @NotNull Document createDefaultModel() {
|
||||||
Document createDefaultModel() {
|
|
||||||
return new ExDocument();
|
return new ExDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +295,8 @@ public class ExTextField extends JTextField {
|
|||||||
void escape() {
|
void escape() {
|
||||||
if (currentAction != null) {
|
if (currentAction != null) {
|
||||||
clearCurrentAction();
|
clearCurrentAction();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -321,7 +324,7 @@ public class ExTextField extends JTextField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Text to show while composing a digraph or inserting a literal or register
|
* Text to show while composing a digraph or inserting a literal or register
|
||||||
* <p>
|
*
|
||||||
* The prompt character is inserted directly into the text of the text field, rather than drawn over the top of the
|
* The prompt character is inserted directly into the text of the text field, rather than drawn over the top of the
|
||||||
* current character. When the action has been completed, the new character(s) are either inserted or overwritten,
|
* current character. When the action has been completed, the new character(s) are either inserted or overwritten,
|
||||||
* depending on the insert/overwrite status of the text field. This mimics Vim's behaviour.
|
* depending on the insert/overwrite status of the text field. This mimics Vim's behaviour.
|
||||||
@ -360,7 +363,7 @@ public class ExTextField extends JTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setInsertMode() {
|
private void setInsertMode() {
|
||||||
ExDocument doc = (ExDocument) getDocument();
|
ExDocument doc = (ExDocument)getDocument();
|
||||||
if (doc.isOverwrite()) {
|
if (doc.isOverwrite()) {
|
||||||
doc.toggleInsertReplace();
|
doc.toggleInsertReplace();
|
||||||
}
|
}
|
||||||
@ -368,7 +371,7 @@ public class ExTextField extends JTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void toggleInsertReplace() {
|
void toggleInsertReplace() {
|
||||||
ExDocument doc = (ExDocument) getDocument();
|
ExDocument doc = (ExDocument)getDocument();
|
||||||
doc.toggleInsertReplace();
|
doc.toggleInsertReplace();
|
||||||
resetCaret();
|
resetCaret();
|
||||||
}
|
}
|
||||||
@ -376,11 +379,13 @@ public class ExTextField extends JTextField {
|
|||||||
private void resetCaret() {
|
private void resetCaret() {
|
||||||
if (getCaretPosition() == super.getText().length() || currentActionPromptCharacterOffset == super.getText().length() - 1) {
|
if (getCaretPosition() == super.getText().length() || currentActionPromptCharacterOffset == super.getText().length() - 1) {
|
||||||
setNormalModeCaret();
|
setNormalModeCaret();
|
||||||
} else {
|
}
|
||||||
ExDocument doc = (ExDocument) getDocument();
|
else {
|
||||||
|
ExDocument doc = (ExDocument)getDocument();
|
||||||
if (doc.isOverwrite()) {
|
if (doc.isOverwrite()) {
|
||||||
setReplaceModeCaret();
|
setReplaceModeCaret();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setInsertModeCaret();
|
setInsertModeCaret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,19 +480,21 @@ public class ExTextField extends JTextField {
|
|||||||
final Area area = new Area(new Rectangle2D.Double(r.getX(), r.getY(), caretWidth, r.getHeight()));
|
final Area area = new Area(new Rectangle2D.Double(r.getX(), r.getY(), caretWidth, r.getHeight()));
|
||||||
area.subtract(new Area(new Rectangle2D.Double(r.getX() + outlineThickness, r.getY() + outlineThickness, caretWidth - (2 * outlineThickness), r.getHeight() - (2 * outlineThickness))));
|
area.subtract(new Area(new Rectangle2D.Double(r.getX() + outlineThickness, r.getY() + outlineThickness, caretWidth - (2 * outlineThickness), r.getHeight() - (2 * outlineThickness))));
|
||||||
g2d.fill(area);
|
g2d.fill(area);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
final double caretHeight = getCaretHeight(r.getHeight());
|
final double caretHeight = getCaretHeight(r.getHeight());
|
||||||
final double caretWidth = getCaretWidth(fm, r.getX(), thickness);
|
final double caretWidth = getCaretWidth(fm, r.getX(), thickness);
|
||||||
g2d.fill(new Rectangle2D.Double(r.getX(), r.getY() + r.getHeight() - caretHeight, caretWidth, caretHeight));
|
g2d.fill(new Rectangle2D.Double(r.getX(), r.getY() + r.getHeight() - caretHeight, caretWidth, caretHeight));
|
||||||
}
|
}
|
||||||
} finally {
|
}
|
||||||
|
finally {
|
||||||
g2d.dispose();
|
g2d.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the bounds of the caret and repaints those bounds.
|
* Updates the bounds of the caret and repaints those bounds.
|
||||||
* <p>
|
*
|
||||||
* This method is not guaranteed to be called before paint(). The bounds are for use by repaint().
|
* This method is not guaranteed to be called before paint(). The bounds are for use by repaint().
|
||||||
*
|
*
|
||||||
* @param r The current location of the caret, usually provided by MapToView. The x and y appear to be the upper
|
* @param r The current location of the caret, usually provided by MapToView. The x and y appear to be the upper
|
||||||
@ -505,21 +512,21 @@ public class ExTextField extends JTextField {
|
|||||||
final FontMetrics fm = getComponent().getFontMetrics(getComponent().getFont());
|
final FontMetrics fm = getComponent().getFontMetrics(getComponent().getFont());
|
||||||
x = r.x;
|
x = r.x;
|
||||||
y = r.y;
|
y = r.y;
|
||||||
width = (int) ceil(getCaretWidth(fm, r.x, 100)) + 1;
|
width = (int)ceil(getCaretWidth(fm, r.x, 100)) + 1;
|
||||||
height = r.height;
|
height = r.height;
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable
|
private @Nullable Rectangle2D modelToView(int dot) {
|
||||||
Rectangle2D modelToView(int dot) {
|
|
||||||
if (dot > getComponent().getDocument().getLength()) {
|
if (dot > getComponent().getDocument().getLength()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return getComponent().getUI().modelToView2D(getComponent(), dot, getDotBias());
|
return getComponent().getUI().modelToView2D(getComponent(), dot, getDotBias());
|
||||||
} catch (BadLocationException e) {
|
}
|
||||||
|
catch (BadLocationException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -532,13 +539,15 @@ public class ExTextField extends JTextField {
|
|||||||
final Rectangle2D r = modelToView(getDot() + 1);
|
final Rectangle2D r = modelToView(getDot() + 1);
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
width = r.getX() - dotX;
|
width = r.getX() - dotX;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
char c = ' ';
|
char c = ' ';
|
||||||
try {
|
try {
|
||||||
if (getDot() < getComponent().getDocument().getLength()) {
|
if (getDot() < getComponent().getDocument().getLength()) {
|
||||||
c = getComponent().getText(getDot(), 1).charAt(0);
|
c = getComponent().getText(getDot(), 1).charAt(0);
|
||||||
}
|
}
|
||||||
} catch (BadLocationException e) {
|
}
|
||||||
|
catch (BadLocationException e) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
width = fm.charWidth(c);
|
width = fm.charWidth(c);
|
||||||
@ -556,8 +565,7 @@ public class ExTextField extends JTextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public @NonNls
|
public @NonNls String getCaretShape() {
|
||||||
String getCaretShape() {
|
|
||||||
CommandLineCaret caret = (CommandLineCaret) getCaret();
|
CommandLineCaret caret = (CommandLineCaret) getCaret();
|
||||||
return String.format("%s %d", caret.mode, caret.thickness);
|
return String.format("%s %d", caret.mode, caret.thickness);
|
||||||
}
|
}
|
||||||
@ -568,8 +576,7 @@ public class ExTextField extends JTextField {
|
|||||||
private String actualText;
|
private String actualText;
|
||||||
private List<HistoryEntry> history;
|
private List<HistoryEntry> history;
|
||||||
private int histIndex = 0;
|
private int histIndex = 0;
|
||||||
private @Nullable
|
private @Nullable MultiStepAction currentAction;
|
||||||
MultiStepAction currentAction;
|
|
||||||
private char currentActionPromptCharacter;
|
private char currentActionPromptCharacter;
|
||||||
private int currentActionPromptCharacterOffset = -1;
|
private int currentActionPromptCharacterOffset = -1;
|
||||||
|
|
||||||
|
@ -37,15 +37,11 @@ internal class GetFunctionHandler : FunctionHandler() {
|
|||||||
return when (container) {
|
return when (container) {
|
||||||
is VimList -> {
|
is VimList -> {
|
||||||
val idx = argumentValues[1].evaluate(editor, context, vimContext).asDouble().toInt()
|
val idx = argumentValues[1].evaluate(editor, context, vimContext).asDouble().toInt()
|
||||||
container.values.getOrElse(idx) {
|
container.values.getOrElse(idx) { argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(-1) }
|
||||||
argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(-1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
is VimDictionary -> {
|
is VimDictionary -> {
|
||||||
val key = argumentValues[1].evaluate(editor, context, vimContext).asString()
|
val key = argumentValues[1].evaluate(editor, context, vimContext).asString()
|
||||||
container.dictionary.getOrElse(VimString(key)) {
|
container.dictionary.getOrElse(VimString(key)) { argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(0) }
|
||||||
argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
is VimBlob, is VimFuncref -> throw ExException("Blobs and Funcref are not supported as an argument for get(). If you need it, request support in YouTrack")
|
is VimBlob, is VimFuncref -> throw ExException("Blobs and Funcref are not supported as an argument for get(). If you need it, request support in YouTrack")
|
||||||
else -> throw ExException("E896: Argument of get() must be a List, Dictionary or Blob")
|
else -> throw ExException("E896: Argument of get() must be a List, Dictionary or Blob")
|
||||||
|
@ -29,7 +29,6 @@ internal object IdeaRefactorModeHelper {
|
|||||||
|
|
||||||
fun keepMode() =
|
fun keepMode() =
|
||||||
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_keep)
|
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_keep)
|
||||||
|
|
||||||
fun selectMode() =
|
fun selectMode() =
|
||||||
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_select)
|
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_select)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import org.antlr.v4.runtime.Recognizer
|
|||||||
|
|
||||||
internal class IdeavimErrorListener : BaseErrorListener() {
|
internal class IdeavimErrorListener : BaseErrorListener() {
|
||||||
private val logger = logger<IdeavimErrorListener>()
|
private val logger = logger<IdeavimErrorListener>()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val testLogger = mutableListOf<String>()
|
val testLogger = mutableListOf<String>()
|
||||||
}
|
}
|
||||||
|
@ -219,8 +219,7 @@ internal object ExpressionVisitor : VimscriptBaseVisitor<Expression>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitOptionExpression(ctx: OptionExpressionContext): Expression {
|
override fun visitOptionExpression(ctx: OptionExpressionContext): Expression {
|
||||||
val result = OptionExpression(Scope.getByValue(ctx.option()?.text ?: "")
|
val result = OptionExpression(Scope.getByValue(ctx.option()?.text ?: "") ?: Scope.GLOBAL_VARIABLE, ctx.option().optionName().text)
|
||||||
?: Scope.GLOBAL_VARIABLE, ctx.option().optionName().text)
|
|
||||||
result.originalString = ctx.text
|
result.originalString = ctx.text
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -602,7 +602,7 @@ class MotionActionTest : VimTestCase() {
|
|||||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VIM-2733
|
// VIM-2733
|
||||||
@Test
|
@Test
|
||||||
fun testDeleteOuterQuoteEmptyString2() {
|
fun testDeleteOuterQuoteEmptyString2() {
|
||||||
val keys = listOf("da'")
|
val keys = listOf("da'")
|
||||||
@ -653,7 +653,7 @@ class MotionActionTest : VimTestCase() {
|
|||||||
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VIM-1427
|
// VIM-1427
|
||||||
@Test
|
@Test
|
||||||
fun testDeleteOuterTagWithCount() {
|
fun testDeleteOuterTagWithCount() {
|
||||||
val keys = listOf("d2at")
|
val keys = listOf("d2at")
|
||||||
|
@ -23,7 +23,7 @@ zl Move the view on the text [count] characters to the
|
|||||||
class ScrollColumnLeftActionTest : VimTestCase() {
|
class ScrollColumnLeftActionTest : VimTestCase() {
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to left`() {
|
fun`test scrolls column to left`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "zl")
|
typeText("100|", "zl")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -32,7 +32,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to left with zRight`() {
|
fun`test scrolls column to left with zRight`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "z<Right>")
|
typeText("100|", "z<Right>")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -41,7 +41,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll first column to left moves cursor`() {
|
fun`test scroll first column to left moves cursor`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "zs", "zl")
|
typeText("100|", "zs", "zl")
|
||||||
assertPosition(0, 100)
|
assertPosition(0, 100)
|
||||||
@ -50,7 +50,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls count columns to left`() {
|
fun`test scrolls count columns to left`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "10zl")
|
typeText("100|", "10zl")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -59,7 +59,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls count columns to left with zRight`() {
|
fun`test scrolls count columns to left with zRight`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "10z<Right>")
|
typeText("100|", "10z<Right>")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -68,7 +68,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to left with sidescrolloff moves cursor`() {
|
fun`test scrolls column to left with sidescrolloff moves cursor`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
enterCommand("set sidescrolloff=10")
|
enterCommand("set sidescrolloff=10")
|
||||||
typeText("100|", "zs", "zl")
|
typeText("100|", "zs", "zl")
|
||||||
@ -78,7 +78,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to left ignores sidescroll`() {
|
fun`test scroll column to left ignores sidescroll`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
enterCommand("set sidescroll=10")
|
enterCommand("set sidescroll=10")
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
@ -95,7 +95,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to left on last page enters virtual space`() {
|
fun`test scroll column to left on last page enters virtual space`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("200|", "ze", "zl")
|
typeText("200|", "ze", "zl")
|
||||||
assertPosition(0, 199)
|
assertPosition(0, 199)
|
||||||
@ -111,7 +111,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
@VimBehaviorDiffers(description = "Vim has virtual space at end of line")
|
@VimBehaviorDiffers(description = "Vim has virtual space at end of line")
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll columns to left on last page does not have full virtual space`() {
|
fun`test scroll columns to left on last page does not have full virtual space`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("200|", "ze", "50zl")
|
typeText("200|", "ze", "50zl")
|
||||||
assertPosition(0, 199)
|
assertPosition(0, 199)
|
||||||
@ -122,7 +122,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to left correctly scrolls inline inlay associated with preceding text`() {
|
fun`test scroll column to left correctly scrolls inline inlay associated with preceding text`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
addInlay(67, true, 5)
|
addInlay(67, true, 5)
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
@ -136,7 +136,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to left correctly scrolls inline inlay associated with following text`() {
|
fun`test scroll column to left correctly scrolls inline inlay associated with following text`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
addInlay(67, false, 5)
|
addInlay(67, false, 5)
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
|
@ -23,7 +23,7 @@ zh Move the view on the text [count] characters to the
|
|||||||
class ScrollColumnRightActionTest : VimTestCase() {
|
class ScrollColumnRightActionTest : VimTestCase() {
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to right`() {
|
fun`test scrolls column to right`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "zh")
|
typeText("100|", "zh")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -32,7 +32,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to right with zLeft`() {
|
fun`test scrolls column to right with zLeft`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "z<Left>")
|
typeText("100|", "z<Left>")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -42,7 +42,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
@VimBehaviorDiffers(description = "Vim has virtual space at the end of line. IdeaVim will scroll up to length of longest line")
|
@VimBehaviorDiffers(description = "Vim has virtual space at the end of line. IdeaVim will scroll up to length of longest line")
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll last column to right moves cursor 1`() {
|
fun`test scroll last column to right moves cursor 1`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("$")
|
typeText("$")
|
||||||
// Assert we got initial scroll correct
|
// Assert we got initial scroll correct
|
||||||
@ -57,7 +57,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
@VimBehaviorDiffers(description = "Vim has virtual space at the end of line. IdeaVim will scroll up to length of longest line")
|
@VimBehaviorDiffers(description = "Vim has virtual space at the end of line. IdeaVim will scroll up to length of longest line")
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll last column to right moves cursor 2`() {
|
fun`test scroll last column to right moves cursor 2`() {
|
||||||
configureByText(
|
configureByText(
|
||||||
buildString {
|
buildString {
|
||||||
repeat(300) { append("0") }
|
repeat(300) { append("0") }
|
||||||
@ -78,7 +78,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls count columns to right`() {
|
fun`test scrolls count columns to right`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "10zh")
|
typeText("100|", "10zh")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -87,7 +87,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls count columns to right with zLeft`() {
|
fun`test scrolls count columns to right with zLeft`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("100|", "10z<Left>")
|
typeText("100|", "10z<Left>")
|
||||||
assertPosition(0, 99)
|
assertPosition(0, 99)
|
||||||
@ -96,7 +96,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scrolls column to right with sidescrolloff moves cursor`() {
|
fun`test scrolls column to right with sidescrolloff moves cursor`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
enterCommand("set sidescrolloff=10")
|
enterCommand("set sidescrolloff=10")
|
||||||
typeText("100|", "ze", "zh")
|
typeText("100|", "ze", "zh")
|
||||||
@ -106,7 +106,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to right ignores sidescroll`() {
|
fun`test scroll column to right ignores sidescroll`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
enterCommand("set sidescroll=10")
|
enterCommand("set sidescroll=10")
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
@ -122,7 +122,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to right on first page does nothing`() {
|
fun`test scroll column to right on first page does nothing`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
typeText("10|", "zh")
|
typeText("10|", "zh")
|
||||||
assertPosition(0, 9)
|
assertPosition(0, 9)
|
||||||
@ -131,7 +131,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to right correctly scrolls inline inlay associated with preceding text`() {
|
fun`test scroll column to right correctly scrolls inline inlay associated with preceding text`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
addInlay(130, true, 5)
|
addInlay(130, true, 5)
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
@ -147,7 +147,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to right correctly scrolls inline inlay associated with following text`() {
|
fun`test scroll column to right correctly scrolls inline inlay associated with following text`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
addInlay(130, false, 5)
|
addInlay(130, false, 5)
|
||||||
typeText("100|")
|
typeText("100|")
|
||||||
@ -163,7 +163,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
|
|||||||
|
|
||||||
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
|
||||||
@Test
|
@Test
|
||||||
fun `test scroll column to right with preceding inline inlay moves cursor at end of screen`() {
|
fun`test scroll column to right with preceding inline inlay moves cursor at end of screen`() {
|
||||||
configureByColumns(200)
|
configureByColumns(200)
|
||||||
addInlay(90, false, 5)
|
addInlay(90, false, 5)
|
||||||
typeText("100|", "ze", "zh")
|
typeText("100|", "ze", "zh")
|
||||||
|
@ -23,9 +23,9 @@ public class ActionLinkFixture extends ComponentFixture {
|
|||||||
|
|
||||||
public void click() {
|
public void click() {
|
||||||
runJs("const offset = component.getHeight()/2;\n" +
|
runJs("const offset = component.getHeight()/2;\n" +
|
||||||
"robot.click(" +
|
"robot.click(" +
|
||||||
"component, " +
|
"component, " +
|
||||||
"new Point(offset, offset), " +
|
"new Point(offset, offset), " +
|
||||||
"MouseButton.LEFT_BUTTON, 1);");
|
"MouseButton.LEFT_BUTTON, 1);");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class Editor(
|
|||||||
get() = callJs("component.getEditor().getCaretModel().getOffset()", runInEdt = true)
|
get() = callJs("component.getEditor().getCaretModel().getOffset()", runInEdt = true)
|
||||||
|
|
||||||
val isBlockCursor: Boolean
|
val isBlockCursor: Boolean
|
||||||
// get() = callJs("component.getEditor().getSettings().isBlockCursor()", true)
|
// get() = callJs("component.getEditor().getSettings().isBlockCursor()", true)
|
||||||
// Doesn't work at the moment because remote robot can't resolve classes from a plugin classloader
|
// Doesn't work at the moment because remote robot can't resolve classes from a plugin classloader
|
||||||
get() = callJs("com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.hasBlockOrUnderscoreCaret(component.getEditor())", true)
|
get() = callJs("com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.hasBlockOrUnderscoreCaret(component.getEditor())", true)
|
||||||
|
|
||||||
|
@ -33,6 +33,6 @@ public class WelcomeFrameFixture extends ContainerFixture {
|
|||||||
|
|
||||||
public ComponentFixture importProjectLink() {
|
public ComponentFixture importProjectLink() {
|
||||||
return find(ComponentFixture.class,
|
return find(ComponentFixture.class,
|
||||||
byXpath("//div[@accessiblename='Get from Version Control...' and @class='JButton']"));
|
byXpath("//div[@accessiblename='Get from Version Control...' and @class='JButton']"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ fun uiTest(testName: String = "test_${System.currentTimeMillis()}", url: String
|
|||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val client by lazy { OkHttpClient() }
|
private val client by lazy { OkHttpClient() }
|
||||||
private fun BufferedImage.save(name: String) {
|
private fun BufferedImage.save(name: String) {
|
||||||
val bytes = ByteArrayOutputStream().use { b ->
|
val bytes = ByteArrayOutputStream().use { b ->
|
||||||
|
@ -33,8 +33,7 @@ public class MotionShiftDownAction : ShiftedArrowKeyHandler(false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
|
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
|
||||||
is Motion.NoMotion -> {
|
is Motion.NoMotion -> {}
|
||||||
}
|
|
||||||
is Motion.Error -> injector.messages.indicateError()
|
is Motion.Error -> injector.messages.indicateError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,7 @@ public class MotionShiftUpAction : ShiftedArrowKeyHandler(false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
|
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
|
||||||
is Motion.NoMotion -> {
|
is Motion.NoMotion -> {}
|
||||||
}
|
|
||||||
is Motion.Error -> injector.messages.indicateError()
|
is Motion.Error -> injector.messages.indicateError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,10 @@ public fun VimEditor.getText(range: TextRange): String {
|
|||||||
public fun VimEditor.getOffset(line: Int, column: Int): Int {
|
public fun VimEditor.getOffset(line: Int, column: Int): Int {
|
||||||
return bufferPositionToOffset(BufferPosition(line, column))
|
return bufferPositionToOffset(BufferPosition(line, column))
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun VimEditor.getLineBuffer(line: Int): CharBuffer {
|
public fun VimEditor.getLineBuffer(line: Int): CharBuffer {
|
||||||
val start: Int = getLineStartOffset(line)
|
val start: Int = getLineStartOffset(line)
|
||||||
return CharBuffer.wrap(text(), start, start + getLineEndOffset(line, true) - getLineStartOffset(line))
|
return CharBuffer.wrap(text(), start, start + getLineEndOffset(line, true) - getLineStartOffset(line))
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun VimEditor.anyNonWhitespace(offset: Int, dir: Int): Boolean {
|
public fun VimEditor.anyNonWhitespace(offset: Int, dir: Int): Boolean {
|
||||||
val start: Int
|
val start: Int
|
||||||
val end: Int
|
val end: Int
|
||||||
|
@ -94,7 +94,6 @@ public interface VimChangeGroup {
|
|||||||
operatorArguments: OperatorArguments,
|
operatorArguments: OperatorArguments,
|
||||||
saveToRegister: Boolean = true,
|
saveToRegister: Boolean = true,
|
||||||
): Boolean
|
): Boolean
|
||||||
|
|
||||||
public fun changeCharacters(editor: VimEditor, caret: VimCaret, operatorArguments: OperatorArguments): Boolean
|
public fun changeCharacters(editor: VimEditor, caret: VimCaret, operatorArguments: OperatorArguments): Boolean
|
||||||
|
|
||||||
public fun changeEndOfLine(editor: VimEditor, caret: VimCaret, count: Int, operatorArguments: OperatorArguments): Boolean
|
public fun changeEndOfLine(editor: VimEditor, caret: VimCaret, count: Int, operatorArguments: OperatorArguments): Boolean
|
||||||
|
@ -178,8 +178,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
|
|||||||
val startOffsets = updatedRange.startOffsets
|
val startOffsets = updatedRange.startOffsets
|
||||||
val endOffsets = updatedRange.endOffsets
|
val endOffsets = updatedRange.endOffsets
|
||||||
for (i in updatedRange.size() - 1 downTo 0) {
|
for (i in updatedRange.size() - 1 downTo 0) {
|
||||||
val (newRange, _) = editor.search(startOffsets[i].offset to endOffsets[i].offset, editor, LineDeleteShift.NL_ON_END)
|
val (newRange, _) = editor.search(startOffsets[i].offset to endOffsets[i].offset, editor, LineDeleteShift.NL_ON_END) ?: continue
|
||||||
?: continue
|
|
||||||
editor.deleteString(TextRange(newRange.first.point, newRange.second.point))
|
editor.deleteString(TextRange(newRange.first.point, newRange.second.point))
|
||||||
}
|
}
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
@ -16,7 +16,6 @@ public abstract class VimCommandGroupBase : VimCommandGroup {
|
|||||||
public companion object {
|
public companion object {
|
||||||
private const val overridePrefix = "!"
|
private const val overridePrefix = "!"
|
||||||
}
|
}
|
||||||
|
|
||||||
private var aliases = HashMap<String, CommandAlias>()
|
private var aliases = HashMap<String, CommandAlias>()
|
||||||
|
|
||||||
override fun isAlias(command: String): Boolean {
|
override fun isAlias(command: String): Boolean {
|
||||||
|
@ -84,265 +84,264 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private val defaultDigraphs = charArrayOf(
|
private val defaultDigraphs = charArrayOf( /*
|
||||||
/*
|
'N', 'U', // 0 ^@
|
||||||
'N', 'U', // 0 ^@
|
'S', 'H', // 1 ^A
|
||||||
'S', 'H', // 1 ^A
|
'S', 'X', // 2 ^B
|
||||||
'S', 'X', // 2 ^B
|
'E', 'X', // 3 ^C
|
||||||
'E', 'X', // 3 ^C
|
'E', 'T', // 4 ^D
|
||||||
'E', 'T', // 4 ^D
|
'E', 'Q', // 5 ^E
|
||||||
'E', 'Q', // 5 ^E
|
'A', 'K', // 6 ^F
|
||||||
'A', 'K', // 6 ^F
|
'B', 'L', // 7 ^G
|
||||||
'B', 'L', // 7 ^G
|
'B', 'S', // 8 ^H
|
||||||
'B', 'S', // 8 ^H
|
'H', 'T', // 9 ^I
|
||||||
'H', 'T', // 9 ^I
|
'L', 'F', // 10 ^J
|
||||||
'L', 'F', // 10 ^J
|
'V', 'T', // 11 ^K
|
||||||
'V', 'T', // 11 ^K
|
'F', 'F', // 12 ^L
|
||||||
'F', 'F', // 12 ^L
|
'C', 'R', // 13 ^M
|
||||||
'C', 'R', // 13 ^M
|
'S', 'O', // 14 ^N
|
||||||
'S', 'O', // 14 ^N
|
'S', 'I', // 15 ^O
|
||||||
'S', 'I', // 15 ^O
|
'D', 'L', // 16 ^P
|
||||||
'D', 'L', // 16 ^P
|
'D', '1', // 17 ^Q
|
||||||
'D', '1', // 17 ^Q
|
'D', '2', // 18 ^R
|
||||||
'D', '2', // 18 ^R
|
'D', '3', // 19 ^S
|
||||||
'D', '3', // 19 ^S
|
'D', '4', // 20 ^T
|
||||||
'D', '4', // 20 ^T
|
'N', 'K', // 21 ^U
|
||||||
'N', 'K', // 21 ^U
|
'S', 'Y', // 22 ^V
|
||||||
'S', 'Y', // 22 ^V
|
'E', 'B', // 23 ^W
|
||||||
'E', 'B', // 23 ^W
|
'C', 'N', // 24 ^X
|
||||||
'C', 'N', // 24 ^X
|
'E', 'M', // 25 ^Y
|
||||||
'E', 'M', // 25 ^Y
|
'S', 'B', // 26 ^Z
|
||||||
'S', 'B', // 26 ^Z
|
'E', 'C', // 27 ^[
|
||||||
'E', 'C', // 27 ^[
|
'F', 'S', // 28 ^\
|
||||||
'F', 'S', // 28 ^\
|
'G', 'S', // 29 ^]
|
||||||
'G', 'S', // 29 ^]
|
'R', 'S', // 30 ^^
|
||||||
'R', 'S', // 30 ^^
|
'U', 'S', // 31 ^_
|
||||||
'U', 'S', // 31 ^_
|
'S', 'P', // 32 Space
|
||||||
'S', 'P', // 32 Space
|
'\0', '\0', // 33 Unused
|
||||||
'\0', '\0', // 33 Unused
|
'\0', '\0', // 34 Unused
|
||||||
'\0', '\0', // 34 Unused
|
'N', 'b', // 35 #
|
||||||
'N', 'b', // 35 #
|
'D', 'O', // 36 $
|
||||||
'D', 'O', // 36 $
|
'\0', '\0', // 37 Unused
|
||||||
'\0', '\0', // 37 Unused
|
'\0', '\0', // 38 Unused
|
||||||
'\0', '\0', // 38 Unused
|
'\0', '\0', // 39 Unused
|
||||||
'\0', '\0', // 39 Unused
|
'\0', '\0', // 40 Unused
|
||||||
'\0', '\0', // 40 Unused
|
'\0', '\0', // 41 Unused
|
||||||
'\0', '\0', // 41 Unused
|
'\0', '\0', // 42 Unused
|
||||||
'\0', '\0', // 42 Unused
|
'\0', '\0', // 43 Unused
|
||||||
'\0', '\0', // 43 Unused
|
'\0', '\0', // 44 Unused
|
||||||
'\0', '\0', // 44 Unused
|
'\0', '\0', // 45 Unused
|
||||||
'\0', '\0', // 45 Unused
|
'\0', '\0', // 46 Unused
|
||||||
'\0', '\0', // 46 Unused
|
'\0', '\0', // 47 Unused
|
||||||
'\0', '\0', // 47 Unused
|
'\0', '\0', // 48 Unused
|
||||||
'\0', '\0', // 48 Unused
|
'\0', '\0', // 49 Unused
|
||||||
'\0', '\0', // 49 Unused
|
'\0', '\0', // 50 Unused
|
||||||
'\0', '\0', // 50 Unused
|
'\0', '\0', // 51 Unused
|
||||||
'\0', '\0', // 51 Unused
|
'\0', '\0', // 52 Unused
|
||||||
'\0', '\0', // 52 Unused
|
'\0', '\0', // 53 Unused
|
||||||
'\0', '\0', // 53 Unused
|
'\0', '\0', // 54 Unused
|
||||||
'\0', '\0', // 54 Unused
|
'\0', '\0', // 55 Unused
|
||||||
'\0', '\0', // 55 Unused
|
'\0', '\0', // 56 Unused
|
||||||
'\0', '\0', // 56 Unused
|
'\0', '\0', // 57 Unused
|
||||||
'\0', '\0', // 57 Unused
|
'\0', '\0', // 58 Unused
|
||||||
'\0', '\0', // 58 Unused
|
'\0', '\0', // 59 Unused
|
||||||
'\0', '\0', // 59 Unused
|
'\0', '\0', // 60 Unused
|
||||||
'\0', '\0', // 60 Unused
|
'\0', '\0', // 61 Unused
|
||||||
'\0', '\0', // 61 Unused
|
'\0', '\0', // 62 Unused
|
||||||
'\0', '\0', // 62 Unused
|
'\0', '\0', // 63 Unused
|
||||||
'\0', '\0', // 63 Unused
|
'A', 't', // 64 @
|
||||||
'A', 't', // 64 @
|
'\0', '\0', // 65 Unused
|
||||||
'\0', '\0', // 65 Unused
|
'\0', '\0', // 66 Unused
|
||||||
'\0', '\0', // 66 Unused
|
'\0', '\0', // 67 Unused
|
||||||
'\0', '\0', // 67 Unused
|
'\0', '\0', // 68 Unused
|
||||||
'\0', '\0', // 68 Unused
|
'\0', '\0', // 69 Unused
|
||||||
'\0', '\0', // 69 Unused
|
'\0', '\0', // 70 Unused
|
||||||
'\0', '\0', // 70 Unused
|
'\0', '\0', // 71 Unused
|
||||||
'\0', '\0', // 71 Unused
|
'\0', '\0', // 72 Unused
|
||||||
'\0', '\0', // 72 Unused
|
'\0', '\0', // 73 Unused
|
||||||
'\0', '\0', // 73 Unused
|
'\0', '\0', // 74 Unused
|
||||||
'\0', '\0', // 74 Unused
|
'\0', '\0', // 75 Unused
|
||||||
'\0', '\0', // 75 Unused
|
'\0', '\0', // 76 Unused
|
||||||
'\0', '\0', // 76 Unused
|
'\0', '\0', // 77 Unused
|
||||||
'\0', '\0', // 77 Unused
|
'\0', '\0', // 78 Unused
|
||||||
'\0', '\0', // 78 Unused
|
'\0', '\0', // 79 Unused
|
||||||
'\0', '\0', // 79 Unused
|
'\0', '\0', // 80 Unused
|
||||||
'\0', '\0', // 80 Unused
|
'\0', '\0', // 81 Unused
|
||||||
'\0', '\0', // 81 Unused
|
'\0', '\0', // 82 Unused
|
||||||
'\0', '\0', // 82 Unused
|
'\0', '\0', // 83 Unused
|
||||||
'\0', '\0', // 83 Unused
|
'\0', '\0', // 84 Unused
|
||||||
'\0', '\0', // 84 Unused
|
'\0', '\0', // 85 Unused
|
||||||
'\0', '\0', // 85 Unused
|
'\0', '\0', // 86 Unused
|
||||||
'\0', '\0', // 86 Unused
|
'\0', '\0', // 87 Unused
|
||||||
'\0', '\0', // 87 Unused
|
'\0', '\0', // 88 Unused
|
||||||
'\0', '\0', // 88 Unused
|
'\0', '\0', // 89 Unused
|
||||||
'\0', '\0', // 89 Unused
|
'\0', '\0', // 90 Unused
|
||||||
'\0', '\0', // 90 Unused
|
'<', '(', // 91 [
|
||||||
'<', '(', // 91 [
|
'/', '/', // 92 \
|
||||||
'/', '/', // 92 \
|
')', '>', // 93 ]
|
||||||
')', '>', // 93 ]
|
'\'', '>', // 94 ^
|
||||||
'\'', '>', // 94 ^
|
'\0', '\0', // 95 Unused
|
||||||
'\0', '\0', // 95 Unused
|
'\'', '!', // 96 `
|
||||||
'\'', '!', // 96 `
|
'\0', '\0', // 97 Unused
|
||||||
'\0', '\0', // 97 Unused
|
'\0', '\0', // 98 Unused
|
||||||
'\0', '\0', // 98 Unused
|
'\0', '\0', // 99 Unused
|
||||||
'\0', '\0', // 99 Unused
|
'\0', '\0', // 100 Unused
|
||||||
'\0', '\0', // 100 Unused
|
'\0', '\0', // 101 Unused
|
||||||
'\0', '\0', // 101 Unused
|
'\0', '\0', // 102 Unused
|
||||||
'\0', '\0', // 102 Unused
|
'\0', '\0', // 103 Unused
|
||||||
'\0', '\0', // 103 Unused
|
'\0', '\0', // 104 Unused
|
||||||
'\0', '\0', // 104 Unused
|
'\0', '\0', // 105 Unused
|
||||||
'\0', '\0', // 105 Unused
|
'\0', '\0', // 106 Unused
|
||||||
'\0', '\0', // 106 Unused
|
'\0', '\0', // 107 Unused
|
||||||
'\0', '\0', // 107 Unused
|
'\0', '\0', // 108 Unused
|
||||||
'\0', '\0', // 108 Unused
|
'\0', '\0', // 109 Unused
|
||||||
'\0', '\0', // 109 Unused
|
'\0', '\0', // 110 Unused
|
||||||
'\0', '\0', // 110 Unused
|
'\0', '\0', // 111 Unused
|
||||||
'\0', '\0', // 111 Unused
|
'\0', '\0', // 112 Unused
|
||||||
'\0', '\0', // 112 Unused
|
'\0', '\0', // 113 Unused
|
||||||
'\0', '\0', // 113 Unused
|
'\0', '\0', // 114 Unused
|
||||||
'\0', '\0', // 114 Unused
|
'\0', '\0', // 115 Unused
|
||||||
'\0', '\0', // 115 Unused
|
'\0', '\0', // 116 Unused
|
||||||
'\0', '\0', // 116 Unused
|
'\0', '\0', // 117 Unused
|
||||||
'\0', '\0', // 117 Unused
|
'\0', '\0', // 118 Unused
|
||||||
'\0', '\0', // 118 Unused
|
'\0', '\0', // 119 Unused
|
||||||
'\0', '\0', // 119 Unused
|
'\0', '\0', // 120 Unused
|
||||||
'\0', '\0', // 120 Unused
|
'\0', '\0', // 121 Unused
|
||||||
'\0', '\0', // 121 Unused
|
'\0', '\0', // 122 Unused
|
||||||
'\0', '\0', // 122 Unused
|
'(', '!', // 123 {
|
||||||
'(', '!', // 123 {
|
'!', '!', // 124 |
|
||||||
'!', '!', // 124 |
|
'!', ')', // 125 }
|
||||||
'!', ')', // 125 }
|
'\'', '?', // 126 ~
|
||||||
'\'', '?', // 126 ~
|
'D', 'T', // 127 ^?
|
||||||
'D', 'T', // 127 ^?
|
'P', 'A', // 128 ~@
|
||||||
'P', 'A', // 128 ~@
|
'H', 'O', // 129 ~A
|
||||||
'H', 'O', // 129 ~A
|
'B', 'H', // 130 ~B
|
||||||
'B', 'H', // 130 ~B
|
'N', 'H', // 131 ~C
|
||||||
'N', 'H', // 131 ~C
|
'I', 'N', // 132 ~D
|
||||||
'I', 'N', // 132 ~D
|
'N', 'L', // 133 ~E
|
||||||
'N', 'L', // 133 ~E
|
'S', 'A', // 134 ~F
|
||||||
'S', 'A', // 134 ~F
|
'E', 'S', // 135 ~G
|
||||||
'E', 'S', // 135 ~G
|
'H', 'S', // 136 ~H
|
||||||
'H', 'S', // 136 ~H
|
'H', 'J', // 137 ~I
|
||||||
'H', 'J', // 137 ~I
|
'V', 'S', // 138 ~J
|
||||||
'V', 'S', // 138 ~J
|
'P', 'D', // 139 ~K
|
||||||
'P', 'D', // 139 ~K
|
'P', 'U', // 140 ~L
|
||||||
'P', 'U', // 140 ~L
|
'R', 'I', // 141 ~M
|
||||||
'R', 'I', // 141 ~M
|
'S', '2', // 142 ~N
|
||||||
'S', '2', // 142 ~N
|
'S', '3', // 143 ~O
|
||||||
'S', '3', // 143 ~O
|
'D', 'C', // 144 ~P
|
||||||
'D', 'C', // 144 ~P
|
'P', '1', // 145 ~Q
|
||||||
'P', '1', // 145 ~Q
|
'P', '2', // 146 ~R
|
||||||
'P', '2', // 146 ~R
|
'T', 'S', // 147 ~S
|
||||||
'T', 'S', // 147 ~S
|
'C', 'C', // 148 ~T
|
||||||
'C', 'C', // 148 ~T
|
'M', 'W', // 149 ~U
|
||||||
'M', 'W', // 149 ~U
|
'S', 'G', // 150 ~V
|
||||||
'S', 'G', // 150 ~V
|
'E', 'G', // 151 ~W
|
||||||
'E', 'G', // 151 ~W
|
'S', 'S', // 152 ~X
|
||||||
'S', 'S', // 152 ~X
|
'G', 'C', // 153 ~Y
|
||||||
'G', 'C', // 153 ~Y
|
'S', 'C', // 154 ~Z
|
||||||
'S', 'C', // 154 ~Z
|
'C', 'I', // 155 ~[
|
||||||
'C', 'I', // 155 ~[
|
'S', 'T', // 156 ~\
|
||||||
'S', 'T', // 156 ~\
|
'O', 'C', // 157 ~]
|
||||||
'O', 'C', // 157 ~]
|
'P', 'M', // 158 ~^
|
||||||
'P', 'M', // 158 ~^
|
'A', 'C', // 159 ~_
|
||||||
'A', 'C', // 159 ~_
|
'N', 'S', // 160 |
|
||||||
'N', 'S', // 160 |
|
'!', 'I', // 161
|
||||||
'!', 'I', // 161
|
'C', 't', // 162
|
||||||
'C', 't', // 162
|
'P', 'd', // 163
|
||||||
'P', 'd', // 163
|
'C', 'u', // 164
|
||||||
'C', 'u', // 164
|
'Y', 'e', // 165
|
||||||
'Y', 'e', // 165
|
'B', 'B', // 166
|
||||||
'B', 'B', // 166
|
'S', 'E', // 167
|
||||||
'S', 'E', // 167
|
'\'', ':', // 168
|
||||||
'\'', ':', // 168
|
'C', 'o', // 169
|
||||||
'C', 'o', // 169
|
'-', 'a', // 170
|
||||||
'-', 'a', // 170
|
'<', '<', // 171
|
||||||
'<', '<', // 171
|
'N', 'O', // 172
|
||||||
'N', 'O', // 172
|
'-', '-', // 173
|
||||||
'-', '-', // 173
|
'R', 'g', // 174
|
||||||
'R', 'g', // 174
|
'\'', 'm', // 175
|
||||||
'\'', 'm', // 175
|
'D', 'G', // 176
|
||||||
'D', 'G', // 176
|
'+', '-', // 177
|
||||||
'+', '-', // 177
|
'2', 'S', // 178
|
||||||
'2', 'S', // 178
|
'3', 'S', // 179
|
||||||
'3', 'S', // 179
|
'\'', '\'', // 180
|
||||||
'\'', '\'', // 180
|
'M', 'y', // 181
|
||||||
'M', 'y', // 181
|
'P', 'I', // 182
|
||||||
'P', 'I', // 182
|
'.', 'M', // 183
|
||||||
'.', 'M', // 183
|
'\'', ',', // 184
|
||||||
'\'', ',', // 184
|
'1', 'S', // 185
|
||||||
'1', 'S', // 185
|
'-', 'o', // 186
|
||||||
'-', 'o', // 186
|
'>', '>', // 187
|
||||||
'>', '>', // 187
|
'1', '4', // 188
|
||||||
'1', '4', // 188
|
'1', '2', // 189
|
||||||
'1', '2', // 189
|
'3', '4', // 190
|
||||||
'3', '4', // 190
|
'?', 'I', // 191
|
||||||
'?', 'I', // 191
|
'A', '!', // 192
|
||||||
'A', '!', // 192
|
'A', '\'', // 193
|
||||||
'A', '\'', // 193
|
'A', '>', // 194
|
||||||
'A', '>', // 194
|
'A', '?', // 195
|
||||||
'A', '?', // 195
|
'A', ':', // 196
|
||||||
'A', ':', // 196
|
'A', 'A', // 197
|
||||||
'A', 'A', // 197
|
'A', 'E', // 198
|
||||||
'A', 'E', // 198
|
'C', ',', // 199
|
||||||
'C', ',', // 199
|
'E', '!', // 200
|
||||||
'E', '!', // 200
|
'E', '\'', // 201
|
||||||
'E', '\'', // 201
|
'E', '>', // 202
|
||||||
'E', '>', // 202
|
'E', ':', // 203
|
||||||
'E', ':', // 203
|
'I', '!', // 204
|
||||||
'I', '!', // 204
|
'I', '\'', // 205
|
||||||
'I', '\'', // 205
|
'I', '>', // 206
|
||||||
'I', '>', // 206
|
'I', ':', // 207
|
||||||
'I', ':', // 207
|
'D', '-', // 208
|
||||||
'D', '-', // 208
|
'N', '?', // 209
|
||||||
'N', '?', // 209
|
'O', '!', // 210
|
||||||
'O', '!', // 210
|
'O', '\'', // 211
|
||||||
'O', '\'', // 211
|
'O', '>', // 212
|
||||||
'O', '>', // 212
|
'O', '?', // 213
|
||||||
'O', '?', // 213
|
'O', ':', // 214
|
||||||
'O', ':', // 214
|
'*', 'X', // 215
|
||||||
'*', 'X', // 215
|
'O', '/', // 216
|
||||||
'O', '/', // 216
|
'U', '!', // 217
|
||||||
'U', '!', // 217
|
'U', '\'', // 218
|
||||||
'U', '\'', // 218
|
'U', '>', // 219
|
||||||
'U', '>', // 219
|
'U', ':', // 220
|
||||||
'U', ':', // 220
|
'Y', '\'', // 221
|
||||||
'Y', '\'', // 221
|
'T', 'H', // 222
|
||||||
'T', 'H', // 222
|
's', 's', // 223
|
||||||
's', 's', // 223
|
'a', '!', // 224
|
||||||
'a', '!', // 224
|
'a', '\'', // 225
|
||||||
'a', '\'', // 225
|
'a', '>', // 226
|
||||||
'a', '>', // 226
|
'a', '?', // 227
|
||||||
'a', '?', // 227
|
'a', ':', // 228
|
||||||
'a', ':', // 228
|
'a', 'a', // 229
|
||||||
'a', 'a', // 229
|
'a', 'e', // 230
|
||||||
'a', 'e', // 230
|
'c', ',', // 231
|
||||||
'c', ',', // 231
|
'e', '!', // 232
|
||||||
'e', '!', // 232
|
'e', '\'', // 233
|
||||||
'e', '\'', // 233
|
'e', '>', // 234
|
||||||
'e', '>', // 234
|
'e', ':', // 235
|
||||||
'e', ':', // 235
|
'i', '!', // 236
|
||||||
'i', '!', // 236
|
'i', '\'', // 237
|
||||||
'i', '\'', // 237
|
'i', '>', // 238
|
||||||
'i', '>', // 238
|
'i', ':', // 239
|
||||||
'i', ':', // 239
|
'd', '-', // 240
|
||||||
'd', '-', // 240
|
'n', '?', // 241
|
||||||
'n', '?', // 241
|
'o', '!', // 242
|
||||||
'o', '!', // 242
|
'o', '\'', // 243
|
||||||
'o', '\'', // 243
|
'o', '>', // 244
|
||||||
'o', '>', // 244
|
'o', '?', // 245
|
||||||
'o', '?', // 245
|
'o', ':', // 246
|
||||||
'o', ':', // 246
|
'-', ':', // 247
|
||||||
'-', ':', // 247
|
'o', '/', // 248
|
||||||
'o', '/', // 248
|
'u', '!', // 249
|
||||||
'u', '!', // 249
|
'u', '\'', // 250
|
||||||
'u', '\'', // 250
|
'u', '>', // 251
|
||||||
'u', '>', // 251
|
'u', ':', // 252
|
||||||
'u', ':', // 252
|
'y', '\'', // 253
|
||||||
'y', '\'', // 253
|
't', 'h', // 254
|
||||||
't', 'h', // 254
|
'y', ':', // 255
|
||||||
'y', ':', // 255
|
*/
|
||||||
*/
|
|
||||||
'N', 'U', '\u0000', // NULL (NUL)
|
'N', 'U', '\u0000', // NULL (NUL)
|
||||||
'S', 'H', '\u0001', // START OF HEADING (SOH)
|
'S', 'H', '\u0001', // START OF HEADING (SOH)
|
||||||
'S', 'X', '\u0002', // START OF TEXT (STX)
|
'S', 'X', '\u0002', // START OF TEXT (STX)
|
||||||
|
@ -13,7 +13,6 @@ import com.maddyhome.idea.vim.mark.Jump
|
|||||||
public abstract class VimJumpServiceBase : VimJumpService {
|
public abstract class VimJumpServiceBase : VimJumpService {
|
||||||
@JvmField
|
@JvmField
|
||||||
protected val jumps: MutableList<Jump> = ArrayList() // todo should it be mutable?
|
protected val jumps: MutableList<Jump> = ArrayList() // todo should it be mutable?
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
protected var jumpSpot: Int = -1
|
protected var jumpSpot: Int = -1
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
|
|||||||
NumberOption(OptionConstants.scroll, "scr", 0),
|
NumberOption(OptionConstants.scroll, "scr", 0),
|
||||||
NumberOption(OptionConstants.scrolloff, "so", 0),
|
NumberOption(OptionConstants.scrolloff, "so", 0),
|
||||||
StringOption(OptionConstants.selection, "sel", "inclusive", isList = false, setOf("old", "inclusive", "exclusive")),
|
StringOption(OptionConstants.selection, "sel", "inclusive", isList = false, setOf("old", "inclusive", "exclusive")),
|
||||||
StringOption(OptionConstants.shell, "sh", if (injector.systemInfoService.isWindows) "cmd.exe" else System.getenv("SHELL")
|
StringOption(OptionConstants.shell, "sh", if (injector.systemInfoService.isWindows) "cmd.exe" else System.getenv("SHELL") ?: "sh"),
|
||||||
?: "sh"),
|
|
||||||
StringOption(OptionConstants.shellxescape, "sxe", if (injector.systemInfoService.isWindows) "\"&|<>()@^" else "", isList = false),
|
StringOption(OptionConstants.shellxescape, "sxe", if (injector.systemInfoService.isWindows) "\"&|<>()@^" else "", isList = false),
|
||||||
ToggleOption(OptionConstants.showcmd, "sc", true),
|
ToggleOption(OptionConstants.showcmd, "sc", true),
|
||||||
ToggleOption(OptionConstants.showmode, "smd", true),
|
ToggleOption(OptionConstants.showmode, "smd", true),
|
||||||
|
@ -52,7 +52,7 @@ public interface VimSearchHelper {
|
|||||||
*/
|
*/
|
||||||
public fun findPreviousCamelStart(chars: CharSequence, endIndex: Int, count: Int): Int?
|
public fun findPreviousCamelStart(chars: CharSequence, endIndex: Int, count: Int): Int?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param chars the char sequence to search in
|
* @param chars the char sequence to search in
|
||||||
* @param startIndex the start index (inclusive)
|
* @param startIndex the start index (inclusive)
|
||||||
* @param count search for the count-th occurrence
|
* @param count search for the count-th occurrence
|
||||||
|
@ -201,7 +201,6 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun findNextWordEnd(
|
public fun findNextWordEnd(
|
||||||
chars: CharSequence,
|
chars: CharSequence,
|
||||||
pos: Int,
|
pos: Int,
|
||||||
|
@ -18,8 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
|
|||||||
*/
|
*/
|
||||||
public interface ExtensionHandler {
|
public interface ExtensionHandler {
|
||||||
@Deprecated("Please use ExtensionHandler#execute(VimEditor, ExecutionContext, OperatorArguments) instead")
|
@Deprecated("Please use ExtensionHandler#execute(VimEditor, ExecutionContext, OperatorArguments) instead")
|
||||||
public fun execute(editor: VimEditor, context: ExecutionContext) {
|
public fun execute(editor: VimEditor, context: ExecutionContext) {}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the action.
|
* Executes the action.
|
||||||
|
@ -54,12 +54,8 @@ public sealed class ShortcutOwnerInfo {
|
|||||||
owners[ShortcutOwner.IDE] = mutableListOf("a")
|
owners[ShortcutOwner.IDE] = mutableListOf("a")
|
||||||
}
|
}
|
||||||
|
|
||||||
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy {
|
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
|
||||||
wights[it] ?: 1000
|
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
|
||||||
}.joinToString(separator = "-")
|
|
||||||
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy {
|
|
||||||
wights[it] ?: 1000
|
|
||||||
}.joinToString(separator = "-")
|
|
||||||
|
|
||||||
return if (ideOwners.isNotEmpty() && vimOwners.isNotEmpty()) {
|
return if (ideOwners.isNotEmpty() && vimOwners.isNotEmpty()) {
|
||||||
ideOwners + ":" + ShortcutOwner.IDE.ownerName + " " + vimOwners + ":" + ShortcutOwner.VIM.ownerName
|
ideOwners + ":" + ShortcutOwner.IDE.ownerName + " " + vimOwners + ":" + ShortcutOwner.VIM.ownerName
|
||||||
|
@ -73,11 +73,11 @@ public object Magic {
|
|||||||
public const val X: Int = 'X'.code - 256
|
public const val X: Int = 'X'.code - 256
|
||||||
public const val z: Int = 'z'.code - 256
|
public const val z: Int = 'z'.code - 256
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Magic characters have a special meaning, they don't match literally.
|
* Magic characters have a special meaning, they don't match literally.
|
||||||
* Magic characters are negative. This separates them from literal characters
|
* Magic characters are negative. This separates them from literal characters
|
||||||
* (possibly multi-byte). Only ASCII characters can be Magic.
|
* (possibly multi-byte). Only ASCII characters can be Magic.
|
||||||
*/
|
*/
|
||||||
public fun magic(x: Int): Int {
|
public fun magic(x: Int): Int {
|
||||||
return x - 256
|
return x - 256
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ public data class ActionCommand(val ranges: Ranges, val argument: String) : Comm
|
|||||||
|
|
||||||
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
|
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
|
||||||
val actionName = argument.trim()
|
val actionName = argument.trim()
|
||||||
val action = injector.actionExecutor.getAction(actionName)
|
val action = injector.actionExecutor.getAction(actionName) ?: throw ExException(injector.messages.message("action.not.found.0", actionName))
|
||||||
?: throw ExException(injector.messages.message("action.not.found.0", actionName))
|
|
||||||
if (injector.application.isUnitTest()) {
|
if (injector.application.isUnitTest()) {
|
||||||
executeAction(editor, action, context)
|
executeAction(editor, action, context)
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,8 +49,7 @@ public class CallCommand(public val ranges: Ranges, public val functionCall: Exp
|
|||||||
return ExecutionResult.Success
|
return ExecutionResult.Success
|
||||||
}
|
}
|
||||||
|
|
||||||
val name = (functionCall.scope?.toString()
|
val name = (functionCall.scope?.toString() ?: "") + functionCall.functionName.evaluate(editor, context, vimContext)
|
||||||
?: "") + functionCall.functionName.evaluate(editor, context, vimContext)
|
|
||||||
val funcref = injector.variableService.getNullableVariableValue(Variable(functionCall.scope, functionCall.functionName), editor, context, vimContext)
|
val funcref = injector.variableService.getNullableVariableValue(Variable(functionCall.scope, functionCall.functionName), editor, context, vimContext)
|
||||||
if (funcref is VimFuncref) {
|
if (funcref is VimFuncref) {
|
||||||
funcref.handler.ranges = ranges
|
funcref.handler.ranges = ranges
|
||||||
|
@ -48,7 +48,6 @@ public data class CmdCommand(val ranges: Ranges, val argument: String) : Command
|
|||||||
const val zeroOrOneArguments = "?"
|
const val zeroOrOneArguments = "?"
|
||||||
const val moreThanZeroArguments = "+"
|
const val moreThanZeroArguments = "+"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
|
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
|
||||||
val result: Boolean = if (argument.trim().isEmpty()) {
|
val result: Boolean = if (argument.trim().isEmpty()) {
|
||||||
this.listAlias(editor, "")
|
this.listAlias(editor, "")
|
||||||
|
@ -53,7 +53,6 @@ public data class LetCommand(
|
|||||||
private companion object {
|
private companion object {
|
||||||
private val logger = vimLogger<LetCommand>()
|
private val logger = vimLogger<LetCommand>()
|
||||||
}
|
}
|
||||||
|
|
||||||
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
|
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
|
||||||
|
|
||||||
@Throws(ExException::class)
|
@Throws(ExException::class)
|
||||||
|
@ -31,8 +31,7 @@ public data class PlugCommand(val ranges: Ranges, val argument: String) : Comman
|
|||||||
return ExecutionResult.Error
|
return ExecutionResult.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
injector.statisticsService.addExtensionEnabledWithPlug(injector.extensionRegistrator.getExtensionNameByAlias(pluginAlias)
|
injector.statisticsService.addExtensionEnabledWithPlug(injector.extensionRegistrator.getExtensionNameByAlias(pluginAlias) ?: "unknown extension")
|
||||||
?: "unknown extension")
|
|
||||||
return ExecutionResult.Success
|
return ExecutionResult.Success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ public data class UnknownCommand(val ranges: Ranges, val name: String, val argum
|
|||||||
val message = injector.messages.message(Msg.NOT_EX_CMD, name)
|
val message = injector.messages.message(Msg.NOT_EX_CMD, name)
|
||||||
throw InvalidCommandException(message, null)
|
throw InvalidCommandException(message, null)
|
||||||
}
|
}
|
||||||
val parsedCommand = injector.vimscriptParser.parseCommand(commandAlias.command)
|
val parsedCommand = injector.vimscriptParser.parseCommand(commandAlias.command) ?: throw ExException("E492: Not an editor command: ${commandAlias.command}")
|
||||||
?: throw ExException("E492: Not an editor command: ${commandAlias.command}")
|
|
||||||
return if (parsedCommand is UnknownCommand) {
|
return if (parsedCommand is UnknownCommand) {
|
||||||
processPossiblyAliasCommand(commandAlias.command, editor, context, aliasCountdown - 1)
|
processPossiblyAliasCommand(commandAlias.command, editor, context, aliasCountdown - 1)
|
||||||
} else {
|
} else {
|
||||||
|
@ -183,8 +183,7 @@ public data class MapCommand(val ranges: Ranges, val argument: String, val cmd:
|
|||||||
}
|
}
|
||||||
return fromKeys?.let {
|
return fromKeys?.let {
|
||||||
val toExpr = if (specialArguments.contains(EXPR)) {
|
val toExpr = if (specialArguments.contains(EXPR)) {
|
||||||
injector.vimscriptParser.parseExpression(toKeysBuilder.toString().trim())
|
injector.vimscriptParser.parseExpression(toKeysBuilder.toString().trim()) ?: throw ExException("E15: Invalid expression: ${toKeysBuilder.toString().trim()}")
|
||||||
?: throw ExException("E15: Invalid expression: ${toKeysBuilder.toString().trim()}")
|
|
||||||
} else {
|
} else {
|
||||||
SimpleExpression(toKeysBuilder.toString().trimStart())
|
SimpleExpression(toKeysBuilder.toString().trimStart())
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,7 @@ public data class DefinedFunctionHandler(val function: FunctionDeclaration) : Fu
|
|||||||
is ExecutionResult.Continue -> exceptionsCaught.add(ExException("E586: :continue without :while or :for: continue"))
|
is ExecutionResult.Continue -> exceptionsCaught.add(ExException("E586: :continue without :while or :for: continue"))
|
||||||
is ExecutionResult.Error -> exceptionsCaught.add(ExException("unknown error occurred")) // todo
|
is ExecutionResult.Error -> exceptionsCaught.add(ExException("unknown error occurred")) // todo
|
||||||
is ExecutionResult.Return -> returnValue = result.value
|
is ExecutionResult.Return -> returnValue = result.value
|
||||||
is ExecutionResult.Success -> {
|
is ExecutionResult.Success -> {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// todo in release 1.9. in this case multiple exceptions can be thrown at once but we don't support it
|
// todo in release 1.9. in this case multiple exceptions can be thrown at once but we don't support it
|
||||||
@ -107,8 +106,7 @@ public data class DefinedFunctionHandler(val function: FunctionDeclaration) : Fu
|
|||||||
returnValue = result.value
|
returnValue = result.value
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
is ExecutionResult.Success -> {
|
is ExecutionResult.Success -> {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: ExException) {
|
} catch (e: ExException) {
|
||||||
if (e is FinishException) {
|
if (e is FinishException) {
|
||||||
|
Loading…
Reference in New Issue
Block a user