1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-08 06:34:08 +02:00

Revert "Update formatting"

This reverts commit bf0fba9c58.
This commit is contained in:
Alex Plate 2023-03-27 11:32:59 +03:00
parent bf0fba9c58
commit 832c1c0be3
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
71 changed files with 1875 additions and 1887 deletions
.idea/fileTemplates/code
src
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -1 +1 @@
com.maddyhome.idea.vim.helper.MessageHelper.message("${PROPERTY_KEY}",${PARAMETERS})
com.maddyhome.idea.vim.helper.MessageHelper.message("${PROPERTY_KEY}", ${PARAMETERS})

View File

@ -30,17 +30,14 @@ import java.awt.event.MouseListener;
* @author vlan
*/
public class EventFacade {
private static final @NotNull
EventFacade ourInstance = new EventFacade();
private static final @NotNull EventFacade ourInstance = new EventFacade();
private @Nullable
TypedActionHandler myOriginalTypedActionHandler;
private @Nullable TypedActionHandler myOriginalTypedActionHandler;
private EventFacade() {
}
public static @NotNull
EventFacade getInstance() {
public static @NotNull EventFacade getInstance() {
return ourInstance;
}
@ -146,8 +143,7 @@ public class EventFacade {
editor.getSelectionModel().removeSelectionListener(listener);
}
private @NotNull
TypedAction getTypedAction() {
private @NotNull TypedAction getTypedAction() {
return TypedAction.getInstance();
}
}

View File

@ -43,15 +43,13 @@ public class RegisterActions {
}, VimPlugin.getInstance());
}
public static @Nullable
EditorActionHandlerBase findAction(@NotNull String id) {
public static @Nullable EditorActionHandlerBase findAction(@NotNull String id) {
return VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream()
.filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst().map(ActionBeanClass::getInstance)
.orElse(null);
.filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst().map(ActionBeanClass::getInstance)
.orElse(null);
}
public static @NotNull
EditorActionHandlerBase findActionOrDie(@NotNull String id) {
public static @NotNull EditorActionHandlerBase findActionOrDie(@NotNull String id) {
EditorActionHandlerBase action = findAction(id);
if (action == null) throw new RuntimeException("Action " + id + " is not registered");
return action;
@ -67,7 +65,7 @@ public class RegisterActions {
private static void registerVimCommandActions() {
KeyGroup parser = VimPlugin.getKey();
VIM_ACTIONS_EP.getExtensionList(ApplicationManager.getApplication()).stream().map(IjVimActionsInitiator::new)
.forEach(parser::registerCommandAction);
.forEach(parser::registerCommandAction);
}
private static void registerEmptyShortcuts() {

View File

@ -70,8 +70,7 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
VimInjectorKt.setInjector(new IjVimInjector());
}
private final @NotNull
VimState state = new VimState();
private final @NotNull VimState state = new VimState();
public Disposable onOffDisposable;
private int previousStateVersion = 0;
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
*/
public static @NotNull
NotificationService getNotifications(@Nullable Project project) {
public static @NotNull NotificationService getNotifications(@Nullable Project project) {
if (project == null) {
return ApplicationManager.getApplication().getService(NotificationService.class);
} else {
}
else {
return project.getService(NotificationService.class);
}
}
public static @NotNull
VimState getVimState() {
public static @NotNull VimState getVimState() {
return getInstance().state;
}
public static @NotNull
MotionGroup getMotion() {
public static @NotNull MotionGroup getMotion() {
return ApplicationManager.getApplication().getService(MotionGroup.class);
}
public static @NotNull
XMLGroup getXML() {
public static @NotNull XMLGroup getXML() {
return ApplicationManager.getApplication().getService(XMLGroup.class);
}
public static @NotNull
ChangeGroup getChange() {
return ((ChangeGroup) VimInjectorKt.getInjector().getChangeGroup());
public static @NotNull ChangeGroup getChange() {
return ((ChangeGroup)VimInjectorKt.getInjector().getChangeGroup());
}
public static @NotNull
CommandGroup getCommand() {
public static @NotNull CommandGroup getCommand() {
return ApplicationManager.getApplication().getService(CommandGroup.class);
}
@Deprecated // "Please use `injector.markService` instead"
@ApiStatus.ScheduledForRemoval(inVersion = "2.3")
public static @NotNull
MarkGroup getMark() {
public static @NotNull MarkGroup getMark() {
return ApplicationManager.getApplication().getService(MarkGroup.class);
}
public static @NotNull
RegisterGroup getRegister() {
return ((RegisterGroup) VimInjectorKt.getInjector().getRegisterGroup());
public static @NotNull RegisterGroup getRegister() {
return ((RegisterGroup)VimInjectorKt.getInjector().getRegisterGroup());
}
public static @NotNull
FileGroup getFile() {
return (FileGroup) VimInjectorKt.getInjector().getFile();
public static @NotNull FileGroup getFile() {
return (FileGroup)VimInjectorKt.getInjector().getFile();
}
public static @NotNull
SearchGroup getSearch() {
public static @NotNull SearchGroup getSearch() {
return ApplicationManager.getApplication().getService(SearchGroup.class);
}
public static @Nullable
SearchGroup getSearchIfCreated() {
public static @Nullable SearchGroup getSearchIfCreated() {
return ApplicationManager.getApplication().getServiceIfCreated(SearchGroup.class);
}
public static @NotNull
ProcessGroup getProcess() {
return ((ProcessGroup) VimInjectorKt.getInjector().getProcessGroup());
public static @NotNull ProcessGroup getProcess() {
return ((ProcessGroup)VimInjectorKt.getInjector().getProcessGroup());
}
public static @NotNull
MacroGroup getMacro() {
return (MacroGroup) VimInjectorKt.getInjector().getMacro();
public static @NotNull MacroGroup getMacro() {
return (MacroGroup)VimInjectorKt.getInjector().getMacro();
}
public static @NotNull
DigraphGroup getDigraph() {
return (DigraphGroup) VimInjectorKt.getInjector().getDigraphGroup();
public static @NotNull DigraphGroup getDigraph() {
return (DigraphGroup)VimInjectorKt.getInjector().getDigraphGroup();
}
public static @NotNull
HistoryGroup getHistory() {
public static @NotNull HistoryGroup getHistory() {
return ApplicationManager.getApplication().getService(HistoryGroup.class);
}
public static @NotNull
KeyGroup getKey() {
return ((KeyGroup) VimInjectorKt.getInjector().getKeyGroup());
public static @NotNull KeyGroup getKey() {
return ((KeyGroup)VimInjectorKt.getInjector().getKeyGroup());
}
public static @Nullable
KeyGroup getKeyIfCreated() {
return ((KeyGroup) ApplicationManager.getApplication().getServiceIfCreated(VimKeyGroup.class));
public static @Nullable KeyGroup getKeyIfCreated() {
return ((KeyGroup)ApplicationManager.getApplication().getServiceIfCreated(VimKeyGroup.class));
}
public static @NotNull
WindowGroup getWindow() {
return ((WindowGroup) VimInjectorKt.getInjector().getWindow());
public static @NotNull WindowGroup getWindow() {
return ((WindowGroup)VimInjectorKt.getInjector().getWindow());
}
public static @NotNull
EditorGroup getEditor() {
public static @NotNull EditorGroup getEditor() {
return ApplicationManager.getApplication().getService(EditorGroup.class);
}
public static @Nullable
EditorGroup getEditorIfCreated() {
public static @Nullable EditorGroup getEditorIfCreated() {
return ApplicationManager.getApplication().getServiceIfCreated(EditorGroup.class);
}
public static @NotNull
VisualMotionGroup getVisualMotion() {
return (VisualMotionGroup) VimInjectorKt.getInjector().getVisualMotionGroup();
public static @NotNull VisualMotionGroup getVisualMotion() {
return (VisualMotionGroup)VimInjectorKt.getInjector().getVisualMotionGroup();
}
public static @NotNull
YankGroupBase getYank() {
return (YankGroupBase) VimInjectorKt.getInjector().getYank();
public static @NotNull YankGroupBase getYank() {
return (YankGroupBase)VimInjectorKt.getInjector().getYank();
}
public static @NotNull
PutGroup getPut() {
return (PutGroup) VimInjectorKt.getInjector().getPut();
public static @NotNull PutGroup getPut() {
return (PutGroup)VimInjectorKt.getInjector().getPut();
}
public static @NotNull
VariableService getVariableService() {
public static @NotNull VariableService getVariableService() {
return ApplicationManager.getApplication().getService(VariableService.class);
}
public static @NotNull
VimOptionGroup getOptionGroup() {
public static @NotNull VimOptionGroup getOptionGroup() {
return VimInjectorKt.getInjector().getOptionGroup();
}
/**
* Deprecated: Use getOptionGroup
*/
/** Deprecated: Use getOptionGroup */
@Deprecated
// Used by which-key 0.8.0, IdeaVimExtension 1.6.5 + 1.6.8
public static @NotNull
OptionService getOptionService() {
public static @NotNull OptionService getOptionService() {
return VimInjectorKt.getInjector().getOptionService();
}
private static @NotNull
NotificationService getNotifications() {
private static @NotNull NotificationService getNotifications() {
return getNotifications(null);
}
public static @NotNull
PluginId getPluginId() {
public static @NotNull PluginId getPluginId() {
return PluginId.getId(IDEAVIM_PLUGIN_ID);
}
public static @NotNull
String getVersion() {
public static @NotNull String getVersion() {
final IdeaPluginDescriptor plugin = PluginManagerCore.getPlugin(getPluginId());
return plugin != null ? plugin.getVersion() : "SNAPSHOT";
}
@ -284,8 +253,7 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
VimInjectorKt.getInjector().getMessages().showStatusBarMessage(null, msg);
}
public static @NotNull
VimPlugin getInstance() {
public static @NotNull VimPlugin getInstance() {
return ApplicationManager.getApplication().getService(VimPlugin.class);
}
@ -296,7 +264,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode()) {
application.invokeAndWait(this::turnOnPlugin);
} else {
}
else {
application.invokeLater(this::turnOnPlugin);
}
}
@ -400,7 +369,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
if (showNotification && VimPlugin.getNotifications().enableRepeatingMode() == Messages.YES) {
getEditor().setKeyRepeat(true);
keyRepeat.setEnabled(true);
} else {
}
else {
getEditor().setKeyRepeat(false);
}
}
@ -432,7 +402,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
if (state != null) {
try {
previousStateVersion = Integer.parseInt(state.getAttributeValue("version"));
} catch (NumberFormatException ignored) {
}
catch (NumberFormatException ignored) {
}
enabled = Boolean.parseBoolean(state.getAttributeValue("enabled"));
previousKeyMap = state.getAttributeValue("keymap");
@ -461,8 +432,8 @@ public class VimPlugin implements PersistentStateComponent<Element>, Disposable
private void legacyStateLoading(@NotNull Element element) {
if (previousStateVersion > 0 && previousStateVersion < 5) {
// Migrate settings from 4 to 5 version
((VimMarkServiceImpl) VimInjectorKt.getInjector().getMarkService()).loadState(element);
((VimJumpServiceImpl) VimInjectorKt.getInjector().getJumpService()).loadState(element);
((VimMarkServiceImpl)VimInjectorKt.getInjector().getMarkService()).loadState(element);
((VimJumpServiceImpl)VimInjectorKt.getInjector().getJumpService()).loadState(element);
getRegister().readData(element);
getSearch().readData(element);
getHistory().readData(element);

View File

@ -28,13 +28,11 @@ public class VimScriptGlobalEnvironment {
private VimScriptGlobalEnvironment() {
}
public static @NotNull
VimScriptGlobalEnvironment getInstance() {
public static @NotNull VimScriptGlobalEnvironment getInstance() {
return ourInstance;
}
public @NotNull
Map<String, Object> getVariables() {
public @NotNull Map<String, Object> getVariables() {
return myVariables;
}
}

View File

@ -18,12 +18,10 @@ import org.jetbrains.annotations.NotNull;
* @author vlan
*/
public interface VimExtension {
@NotNull
ExtensionPointName<ExtensionBeanClass> EP_NAME = ExtensionPointName.create("IdeaVIM.vimExtension");
@NotNull ExtensionPointName<ExtensionBeanClass> EP_NAME = ExtensionPointName.create("IdeaVIM.vimExtension");
@VimNlsSafe
@NotNull
String getName();
@NotNull String getName();
default MappingOwner getOwner() {
return MappingOwner.Plugin.Companion.get(getName());

View File

@ -42,8 +42,7 @@ import static com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingI
public class VimArgTextObjExtension implements VimExtension {
@Override
public @NotNull
String getName() {
public @NotNull String getName() {
return "argtextobj";
}
@ -62,10 +61,8 @@ public class VimArgTextObjExtension implements VimExtension {
*/
private static class BracketPairs {
// NOTE: brackets must match by the position, and ordered by rank (highest to lowest).
@NotNull
private final String openBrackets;
@NotNull
private final String closeBrackets;
@NotNull private final String openBrackets;
@NotNull private final String closeBrackets;
static class ParseException extends Exception {
public ParseException(@NotNull String message) {
@ -213,8 +210,8 @@ public class VimArgTextObjExtension implements VimExtension {
return null;
}
}
final ArgBoundsFinder finder = new ArgBoundsFinder(((IjVimEditor) editor).getEditor().getDocument(), bracketPairs);
int pos = ((IjVimCaret) caret).getCaret().getOffset();
final ArgBoundsFinder finder = new ArgBoundsFinder(((IjVimEditor)editor).getEditor().getDocument(), bracketPairs);
int pos = ((IjVimCaret)caret).getCaret().getOffset();
for (int i = 0; i < count; ++i) {
if (!finder.findBoundsAt(pos)) {
@ -261,14 +258,14 @@ public class VimArgTextObjExtension implements VimExtension {
if (vimStateMachine.getMode() == VimStateMachine.Mode.VISUAL) {
com.maddyhome.idea.vim.group.visual.EngineVisualGroupKt.vimSetSelection(caret, range.getStartOffset(), range.getEndOffset() - 1, true);
} else {
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret) caret).getCaret(), range.getStartOffset());
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret)caret).getCaret(), range.getStartOffset());
}
}
}
});
} else {
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
*/
private static class ArgBoundsFinder {
@NotNull
private final CharSequence text;
@NotNull
private final Document document;
@NotNull
private final BracketPairs brackets;
@NotNull private final CharSequence text;
@NotNull private final Document document;
@NotNull private final BracketPairs brackets;
private int leftBound = Integer.MAX_VALUE;
private int rightBound = Integer.MIN_VALUE;
private int leftBracket;
private int rightBracket;
private @Nls
String error = null;
private @Nls String error = null;
private static final String QUOTES = "\"'";
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
* 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).
*/
private void getOutOfQuotedText() {

View File

@ -44,7 +44,7 @@ import static com.maddyhome.idea.vim.extension.VimExtensionFacade.putKeyMappingI
* <li>Then copy the resulting text to another application ("*yie)</li>
* </ul>
* </ul>
* <p>
*
* See also the reference manual for more details at:
* https://github.com/kana/vim-textobj-entire/blob/master/doc/textobj-entire.txt
*
@ -62,7 +62,7 @@ public class VimTextObjEntireExtension implements VimExtension {
@Override
public void init() {
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(),
new VimTextObjEntireExtension.EntireHandler(true), false);
@ -97,12 +97,12 @@ public class VimTextObjEntireExtension implements VimExtension {
int count,
int rawCount,
@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
// so we have to scan the document text to find the correct start & end
if (ignoreLeadingAndTrailing) {
String content = ((IjVimEditor) editor).getEditor().getDocument().getText();
String content = ((IjVimEditor)editor).getEditor().getDocument().getText();
for (int i = 0; i < content.length(); ++i) {
if (!Character.isWhitespace(content.charAt(i))) {
start = i;
@ -151,8 +151,8 @@ public class VimTextObjEntireExtension implements VimExtension {
});
} else {
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
}
}
}

View File

@ -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>iI</code> <b>I</b>nner <b>I</b>ndentation level (no lines above and below). Synonym of <code>ii</code></li>
* </ul>
* <p>
*
* See also the reference manual for more details at:
* https://github.com/michaeljsmith/vim-indent-object/blob/master/doc/indent-object.txt
*
@ -58,7 +58,7 @@ public class VimIndentObject implements VimExtension {
@Override
public void init() {
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(),
new IndentObject(true, true), false);
putExtensionHandlerMapping(MappingMode.XO, VimInjectorKt.getInjector().getParser().parseKeys("<Plug>textobj-indent-ii"), getOwner(),
@ -100,8 +100,8 @@ public class VimIndentObject implements VimExtension {
int count,
int rawCount,
@Nullable Argument argument) {
final CharSequence charSequence = ((IjVimEditor) editor).getEditor().getDocument().getCharsSequence();
final int caretOffset = ((IjVimCaret) caret).getCaret().getOffset();
final CharSequence charSequence = ((IjVimEditor)editor).getEditor().getDocument().getCharsSequence();
final int caretOffset = ((IjVimCaret)caret).getCaret().getOffset();
// Part 1: Find the start of the caret line.
int caretLineStartOffset = caretOffset;
@ -257,14 +257,14 @@ public class VimIndentObject implements VimExtension {
@Override
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);
int count = Math.max(1, vimStateMachine.getCommandBuilder().getCount());
final IndentObjectHandler textObjectHandler = new IndentObjectHandler(includeAbove, includeBelow);
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);
if (range != null) {
try (VimListenerSuppressor.Locked ignored = SelectionVimListenerSuppressor.INSTANCE.lock()) {
@ -279,8 +279,8 @@ public class VimIndentObject implements VimExtension {
});
} else {
vimStateMachine.getCommandBuilder().completeCommandPart(new Argument(new Command(count,
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
textObjectHandler, Command.Type.MOTION,
EnumSet.noneOf(CommandFlags.class))));
}
}
}

View File

@ -77,8 +77,7 @@ public class ChangeGroup extends VimChangeGroupBase {
private long lastShownTime = 0L;
private final @NotNull
EditorMouseListener listener = new EditorMouseListener() {
private final @NotNull EditorMouseListener listener = new EditorMouseListener() {
@Override
public void mouseClicked(@NotNull EditorMouseEvent event) {
Editor editor = event.getEditor();
@ -102,20 +101,20 @@ public class ChangeGroup extends VimChangeGroupBase {
DataContext ijContext = IjEditorExecutionContextKt.getIj(context);
final Document doc = ((IjVimEditor) vimEditor).getEditor().getDocument();
CommandProcessor.getInstance().executeCommand(editor.getProject(), () -> ApplicationManager.getApplication()
.runWriteAction(() -> KeyHandlerKeeper.getInstance().getOriginalHandler().execute(editor, key, ijContext)), "", doc,
UndoConfirmationPolicy.DEFAULT, doc);
.runWriteAction(() -> KeyHandlerKeeper.getInstance().getOriginalHandler().execute(editor, key, ijContext)), "", doc,
UndoConfirmationPolicy.DEFAULT, doc);
injector.getScroll().scrollCaretIntoView(vimEditor);
}
@Override
public @Nullable
Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
@NotNull VimCaret caret,
@NotNull ExecutionContext context,
final @NotNull Argument argument,
boolean isChange,
@NotNull OperatorArguments operatorArguments) {
public @Nullable Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
@NotNull VimCaret caret,
@NotNull ExecutionContext context,
final @NotNull Argument argument,
boolean isChange,
@NotNull OperatorArguments operatorArguments) {
final TextRange range = MotionGroup.getMotionRange2(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), ((IjEditorExecutionContext) context).getContext(), argument, operatorArguments);
if (range == null) return null;
@ -126,7 +125,8 @@ public class ChangeGroup extends VimChangeGroupBase {
SelectionType type;
if (argument.getMotion().isLinewiseMotion()) {
type = SelectionType.LINE_WISE;
} else {
}
else {
type = SelectionType.CHARACTER_WISE;
}
final Command motion = argument.getMotion();
@ -161,11 +161,11 @@ public class ChangeGroup extends VimChangeGroupBase {
Motion motion = injector.getMotion().getHorizontalMotion(editor, caret, count, true, allowWrap);
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
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;
}
@ -180,13 +180,14 @@ public class ChangeGroup extends VimChangeGroupBase {
final BufferPosition startPosition = editor.offsetToBufferPosition(range.getStartOffset());
boolean visualBlockMode = operatorArguments.getMode() == VimStateMachine.Mode.VISUAL &&
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
operatorArguments.getSubMode() == VimStateMachine.SubMode.VISUAL_BLOCK;
for (VimCaret caret : editor.carets()) {
final int line = startPosition.getLine();
int column = startPosition.getColumn();
if (!visualBlockMode) {
column = 0;
} else if (append) {
}
else if (append) {
column += range.getMaxLength();
if (caret.getVimLastColumn() == VimMotionGroupBase.LAST_COLUMN) {
column = VimMotionGroupBase.LAST_COLUMN;
@ -201,7 +202,7 @@ public class ChangeGroup extends VimChangeGroupBase {
}
if (visualBlockMode || !append) {
InlayHelperKt.moveToInlayAwareLogicalPosition(((IjVimCaret) caret).getCaret(), new LogicalPosition(line, column));
InlayHelperKt.moveToInlayAwareLogicalPosition(((IjVimCaret)caret).getCaret(), new LogicalPosition(line, column));
}
if (visualBlockMode) {
setInsertRepeat(lines, column, append);
@ -210,7 +211,8 @@ public class ChangeGroup extends VimChangeGroupBase {
if (visualBlockMode || !append) {
insertBeforeCursor(editor, context);
} else {
}
else {
insertAfterCursor(editor, context);
}
@ -286,7 +288,7 @@ public class ChangeGroup extends VimChangeGroupBase {
@NotNull Argument argument,
@NotNull OperatorArguments operatorArguments) {
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
operatorArguments);
operatorArguments);
return range != null && changeCaseRange(editor, caret, range, type);
}
@ -297,7 +299,7 @@ public class ChangeGroup extends VimChangeGroupBase {
@NotNull Argument argument,
@NotNull OperatorArguments operatorArguments) {
final TextRange range = injector.getMotion().getMotionRange(editor, caret, context, argument,
operatorArguments);
operatorArguments);
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);
if (range != null) {
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 endOffset = EngineEditorHelperKt.getLineEndForOffset(editor, range.getEndOffset());
Editor ijEditor = ((IjVimEditor) editor).getEditor();
Editor ijEditor = ((IjVimEditor)editor).getEditor();
VisualModeHelperKt.vimSetSystemSelectionSilently(ijEditor.getSelectionModel(), startOffset, endOffset);
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 newOffset = injector.getMotion().moveCaretToLineStartSkipLeading(editor, firstLine);
caret.moveToOffset(newOffset);
restoreCursor(editor, caret, ((IjVimCaret) caret).getCaret().getLogicalPosition().line);
restoreCursor(editor, caret, ((IjVimCaret)caret).getCaret().getLogicalPosition().line);
return null;
};
if (project != null) {
@ -440,7 +442,8 @@ public class ChangeGroup extends VimChangeGroupBase {
insertText(editor, caret, spos, indent);
}
}
} else {
}
else {
// Left shift blockwise selection
CharSequence chars = editor.text();
for (int l = sline; l <= eline; l++) {
@ -462,7 +465,8 @@ public class ChangeGroup extends VimChangeGroupBase {
}
}
}
} else {
}
else {
// Shift non-blockwise selection
for (int l = sline; l <= eline; l++) {
final int soff = editor.getLineStartOffset(l);
@ -483,7 +487,8 @@ public class ChangeGroup extends VimChangeGroupBase {
VimCaret newCaret = caret.setVimLastColumnAndGetCaret(intendedColumn);
final int offset = injector.getMotion().moveCaretToLineWithStartOfLineOption(editor, sline, caret);
newCaret.moveToOffset(offset);
} else {
}
else {
caret.moveToOffset(range.getStartOffset());
}
}
@ -559,10 +564,10 @@ public class ChangeGroup extends VimChangeGroupBase {
ApplicationManager.getApplication().invokeLater(() -> {
final Balloon balloon = JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder("Wow, nice vim skills!", VimIcons.IDEAVIM,
MessageType.INFO.getTitleForeground(), MessageType.INFO.getPopupBackground(),
null).createBalloon();
balloon.show(JBPopupFactory.getInstance().guessBestPopupLocation(((IjVimEditor) editor).getEditor()),
Balloon.Position.below);
MessageType.INFO.getTitleForeground(), MessageType.INFO.getPopupBackground(),
null).createBalloon();
balloon.show(JBPopupFactory.getInstance().guessBestPopupLocation(((IjVimEditor)editor).getEditor()),
Balloon.Position.below);
});
}
}
@ -612,7 +617,8 @@ public class ChangeGroup extends VimChangeGroupBase {
String newNumber = changeNumberInRange(editor, range, count, alpha, hex, octal);
if (newNumber == null) {
return false;
} else {
}
else {
replaceText(editor, caret, range.getFirst().getStartOffset(), range.getFirst().getEndOffset(), newNumber);
InlayHelperKt.moveToInlayAwareOffset(((IjVimCaret) caret).getCaret(), range.getFirst().getStartOffset() + newNumber.length() - 1);
return true;
@ -634,13 +640,12 @@ public class ChangeGroup extends VimChangeGroupBase {
strokes.add(chars);
}
private @Nullable
String changeNumberInRange(final @NotNull VimEditor editor,
Pair<TextRange, NumberType> range,
final int count,
boolean alpha,
boolean hex,
boolean octal) {
private @Nullable String changeNumberInRange(final @NotNull VimEditor editor,
Pair<TextRange, NumberType> range,
final int count,
boolean alpha,
boolean hex,
boolean octal) {
String text = EngineEditorHelperKt.getText(editor, range.getFirst());
NumberType numberType = range.getSecond();
if (logger.isDebugEnabled()) {
@ -678,7 +683,8 @@ public class ChangeGroup extends VimChangeGroupBase {
}
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);
BigInteger num = new BigInteger(text, 8).add(BigInteger.valueOf(count));
@ -687,13 +693,15 @@ public class ChangeGroup extends VimChangeGroupBase {
}
number = num.toString(8);
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);
ch += count;
if (Character.isLetter(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);
boolean pad = ch == '0';
int len = text.length();
@ -732,7 +740,7 @@ public class ChangeGroup extends VimChangeGroupBase {
@Override
public void notifyListeners(@NotNull VimEditor editor) {
insertListeners.forEach(listener -> listener.insertModeStarted(((IjVimEditor) editor).getEditor()));
insertListeners.forEach(listener -> listener.insertModeStarted(((IjVimEditor)editor).getEditor()));
}
@Override
@ -742,5 +750,6 @@ public class ChangeGroup extends VimChangeGroupBase {
}
private static final Logger logger = Logger.getInstance(ChangeGroup.class.getName());
}

View File

@ -24,7 +24,7 @@ public class DigraphGroup extends VimDigraphGroupBase {
width = 80;
}
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()) {
logger.debug("width=" + width);
@ -41,11 +41,13 @@ public class DigraphGroup extends VimDigraphGroupBase {
res.append(' ');
if (code < 32) {
res.append('^');
res.append((char) (code + '@'));
} else if (code >= 128 && code <= 159) {
res.append((char)(code + '@'));
}
else if (code >= 128 && code <= 159) {
res.append('~');
res.append((char) (code - 128 + '@'));
} else {
res.append((char)(code - 128 + '@'));
}
else {
res.append(code);
res.append(' ');
}

View File

@ -49,8 +49,7 @@ import static com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.update
*/
@State(name = "VimEditorSettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
public class EditorGroup implements PersistentStateComponent<Element>, VimEditorGroup {
public static final @NonNls
String EDITOR_STORE_ELEMENT = "editor";
public static final @NonNls String EDITOR_STORE_ELEMENT = "editor";
private Boolean isKeyRepeat = null;
@ -126,7 +125,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
if (!hasRelativeLineNumbersInstalled(editor)) {
installRelativeLineNumbers(editor);
}
} else if (hasRelativeLineNumbersInstalled(editor)) {
}
else if (hasRelativeLineNumbersInstalled(editor)) {
removeRelativeLineNumbers(editor);
}
}
@ -192,8 +192,7 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
}
}
public @Nullable
Boolean isKeyRepeat() {
public @Nullable Boolean isKeyRepeat() {
return isKeyRepeat;
}
@ -215,8 +214,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
initLineNumbers(editor);
// Turn on insert mode if editor doesn't have any file
if (!EditorHelper.isFileEditor(editor) &&
editor.getDocument().isWritable() &&
!CommandStateHelper.inInsertMode(editor)) {
editor.getDocument().isWritable() &&
!CommandStateHelper.inInsertMode(editor)) {
ExecutionContext.Editor context = injector.getExecutionContextManager().onEditor(new IjVimEditor(editor), null);
VimPlugin.getChange().insertBeforeCursor(new IjVimEditor(editor), context);
KeyHandler.getInstance().reset(new IjVimEditor(editor));
@ -277,7 +276,7 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
@Override
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)) {
updateLineNumbers(ijEditor);
@ -294,7 +293,8 @@ public class EditorGroup implements PersistentStateComponent<Element>, VimEditor
// lineNumber is 1 based
if (number && (lineNumber - 1) == caretLine) {
return lineNumber;
} else {
}
else {
final int visualLine = new IjVimEditor(editor).bufferLineToVisualLine(lineNumber - 1);
final int currentVisualLine = new IjVimEditor(editor).bufferLineToVisualLine(caretLine);
return Math.abs(currentVisualLine - visualLine);

View File

@ -72,20 +72,21 @@ public class FileGroup extends VimFileBase {
fem.openFile(found, true);
return true;
} else {
}
else {
// 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;
}
} else {
}
else {
VimPlugin.showMessage(MessageHelper.message("unable.to.find.0", filename));
return false;
}
}
@Nullable
VirtualFile findFile(@NotNull String filename, @NotNull Project project) {
@Nullable VirtualFile findFile(@NotNull String filename, @NotNull Project project) {
VirtualFile found;
if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
String homefile = filename.substring(2);
@ -95,7 +96,8 @@ public class FileGroup extends VimFileBase {
logger.debug("looking for " + homefile + " in " + dir);
}
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
} else {
}
else {
found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
if (found == null) {
@ -141,11 +143,11 @@ public class FileGroup extends VimFileBase {
*/
@Override
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) {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
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) {
window.closeFile(virtualFile);
@ -171,8 +173,7 @@ public class FileGroup extends VimFileBase {
if (number >= 0 && number < editors.length) {
fileEditorManager.closeFile(editors[number], window);
}
}
if (!ApplicationManager.getApplication().isUnitTestMode()) {
} if (!ApplicationManager.getApplication().isUnitTestMode()) {
// This thing doesn't have an implementation in test mode
EditorsSplitters.focusDefaultComponentInSplittersIfPresent(project);
}
@ -186,7 +187,8 @@ public class FileGroup extends VimFileBase {
NativeAction action;
if (globalOptions(injector).hasValue(IjOptionConstants.ideawrite, IjOptionConstants.ideawrite_all)) {
action = injector.getNativeActionManager().getSaveAll();
} else {
}
else {
action = injector.getNativeActionManager().getSaveCurrent();
}
ExecuteExtensionKt.execute(action, context);
@ -243,12 +245,13 @@ public class FileGroup extends VimFileBase {
*/
@Override
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;
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
if (vf != null && vf.isValid()) {
FileEditorManager.getInstance(project).openFile(vf, true);
} else {
}
else {
VimPlugin.indicateError();
}
}
@ -256,8 +259,7 @@ public class FileGroup extends VimFileBase {
/**
* Returns the previous tab.
*/
public @Nullable
VirtualFile getPreviousTab(@NotNull DataContext context) {
public @Nullable VirtualFile getPreviousTab(@NotNull DataContext context) {
Project project = PlatformDataKeys.PROJECT.getData(context);
if (project == null) return null;
VirtualFile vf = LastTabService.getInstance(project).getLastTab();
@ -267,13 +269,12 @@ public class FileGroup extends VimFileBase {
return null;
}
@Nullable
Editor selectEditor(Project project, @NotNull VirtualFile file) {
@Nullable Editor selectEditor(Project project, @NotNull VirtualFile file) {
FileEditorManager fMgr = FileEditorManager.getInstance(project);
FileEditor[] feditors = fMgr.openFile(file, true);
if (feditors.length > 0) {
if (feditors[0] instanceof TextEditor) {
Editor editor = ((TextEditor) feditors[0]).getEditor();
Editor editor = ((TextEditor)feditors[0]).getEditor();
if (!editor.isDisposed()) {
return editor;
}
@ -285,7 +286,7 @@ public class FileGroup extends VimFileBase {
@Override
public void displayLocationInfo(@NotNull VimEditor vimEditor) {
Editor editor = ((IjVimEditor) vimEditor).getEditor();
Editor editor = ((IjVimEditor)vimEditor).getEditor();
StringBuilder msg = new StringBuilder();
Document doc = editor.getDocument();
@ -322,11 +323,12 @@ public class FileGroup extends VimFileBase {
int size = EditorHelperRt.getFileSize(editor);
msg.append("; Character ").append(offset + 1).append(" of ").append(size);
} else {
}
else {
msg.append("Selected ");
TextRange vr = new TextRange(editor.getSelectionModel().getBlockSelectionStarts(),
editor.getSelectionModel().getBlockSelectionEnds());
editor.getSelectionModel().getBlockSelectionEnds());
vr.normalize();
int lines;
@ -343,7 +345,8 @@ public class FileGroup extends VimFileBase {
cp = SearchHelper.countWords(editor, vr.getStartOffsets()[i], vr.getEndOffsets()[i] - 1);
word += cp.getCount();
}
} else {
}
else {
LogicalPosition slp = editor.offsetToLogicalPosition(vr.getStartOffset());
LogicalPosition elp = editor.offsetToLogicalPosition(vr.getEndOffset());
@ -370,39 +373,43 @@ public class FileGroup extends VimFileBase {
@Override
public void displayFileInfo(@NotNull VimEditor vimEditor, boolean fullPath) {
Editor editor = ((IjVimEditor) vimEditor).getEditor();
Editor editor = ((IjVimEditor)vimEditor).getEditor();
StringBuilder msg = new StringBuilder();
VirtualFile vf = EditorHelper.getVirtualFile(editor);
if (vf != null) {
msg.append('"');
if (fullPath) {
msg.append(vf.getPath());
} else {
}
else {
Project project = editor.getProject();
if (project != null) {
VirtualFile root = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(vf);
if (root != null) {
msg.append(vf.getPath().substring(root.getPath().length() + 1));
} else {
}
else {
msg.append(vf.getPath());
}
}
}
msg.append("\" ");
} else {
}
else {
msg.append("\"[No File]\" ");
}
Document doc = editor.getDocument();
if (!doc.isWritable()) {
msg.append("[RO] ");
} else if (FileDocumentManager.getInstance().isDocumentUnsaved(doc)) {
}
else if (FileDocumentManager.getInstance().isDocumentUnsaved(doc)) {
msg.append("[+] ");
}
int lline = editor.getCaretModel().getLogicalPosition().line;
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(" --").append(pct).append("%-- ");
@ -418,8 +425,7 @@ public class FileGroup extends VimFileBase {
VimPlugin.showMessage(msg.toString());
}
private static final @NotNull
Logger logger = Logger.getInstance(FileGroup.class.getName());
private static final @NotNull 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.

View File

@ -55,13 +55,10 @@ import static java.util.stream.Collectors.toList;
* @author vlan
*/
@State(name = "VimKeySettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponent<Element> {
public static final @NonNls
String SHORTCUT_CONFLICTS_ELEMENT = "shortcut-conflicts";
private static final @NonNls
String SHORTCUT_CONFLICT_ELEMENT = "shortcut-conflict";
private static final @NonNls
String OWNER_ATTRIBUTE = "owner";
public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponent<Element>{
public static final @NonNls String SHORTCUT_CONFLICTS_ELEMENT = "shortcut-conflicts";
private static final @NonNls String SHORTCUT_CONFLICT_ELEMENT = "shortcut-conflict";
private static final @NonNls String OWNER_ATTRIBUTE = "owner";
private static final String TEXT_ELEMENT = "text";
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) {
EventFacade.getInstance()
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
((IjVimEditor) editor).getEditor().getComponent());
((IjVimEditor)editor).getEditor().getComponent());
}
public void registerShortcutsForLookup(@NotNull LookupImpl lookup) {
EventFacade.getInstance()
.registerCustomShortcutSet(VimShortcutKeyAction.getInstance(), toShortcutSet(getRequiredShortcutKeys()),
lookup.getComponent(), lookup);
lookup.getComponent(), lookup);
}
void unregisterShortcutKeys(@NotNull VimEditor editor) {
EventFacade.getInstance().unregisterCustomShortcutSet(VimShortcutKeyAction.getInstance(),
((IjVimEditor) editor).getEditor().getComponent());
((IjVimEditor)editor).getEditor().getComponent());
}
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;
ShortcutOwnerInfo myValue = entry.getValue();
if (myValue instanceof ShortcutOwnerInfo.AllModes) {
owner = ((ShortcutOwnerInfo.AllModes) myValue).getOwner();
} else if (myValue instanceof ShortcutOwnerInfo.PerMode) {
owner = ((ShortcutOwnerInfo.AllModes)myValue).getOwner();
}
else if (myValue instanceof ShortcutOwnerInfo.PerMode) {
owner = null;
} else {
}
else {
throw new RuntimeException();
}
if (owner != null && owner != ShortcutOwner.UNDEFINED) {
@ -143,7 +142,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
ShortcutOwner owner = ShortcutOwner.UNDEFINED;
try {
owner = ShortcutOwner.fromString(ownerValue);
} catch (IllegalArgumentException ignored) {
}
catch (IllegalArgumentException ignored) {
}
final Element textElement = conflictElement.getChild(TEXT_ELEMENT);
if (textElement != null) {
@ -160,8 +160,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
}
@Override
public @NotNull
List<NativeAction> getKeymapConflicts(@NotNull KeyStroke keyStroke) {
public @NotNull List<NativeAction> getKeymapConflicts(@NotNull KeyStroke keyStroke) {
final KeymapManagerEx keymapManager = KeymapManagerEx.getInstanceEx();
final Keymap keymap = keymapManager.getActiveKeymap();
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());
}
public @NotNull
Map<KeyStroke, ShortcutOwnerInfo> getShortcutConflicts() {
public @NotNull Map<KeyStroke, ShortcutOwnerInfo> getShortcutConflicts() {
final Set<RequiredShortcut> requiredShortcutKeys = this.getRequiredShortcutKeys();
final Map<KeyStroke, ShortcutOwnerInfo> savedConflicts = getSavedShortcutConflicts();
final Map<KeyStroke, ShortcutOwnerInfo> results = new HashMap<>();
@ -212,13 +210,13 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
}
public void registerCommandAction(@NotNull VimActionsInitiator actionHolder) {
IjVimActionsInitiator holder = (IjVimActionsInitiator) actionHolder;
IjVimActionsInitiator holder = (IjVimActionsInitiator)actionHolder;
if (!VimPlugin.getPluginId().equals(holder.getBean().getPluginDescriptor().getPluginId())) {
logger.error("IdeaVim doesn't accept contributions to `vimActions` extension points. " +
"Please create a plugin using `VimExtension`. " +
"Plugin to blame: " +
holder.getBean().getPluginDescriptor().getPluginId());
"Please create a plugin using `VimExtension`. " +
"Plugin to blame: " +
holder.getBean().getPluginDescriptor().getPluginId());
return;
}
@ -226,8 +224,9 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
if (actionKeys == null) {
final EditorActionHandlerBase action = actionHolder.getInstance();
if (action instanceof ComplicatedKeysAction) {
actionKeys = ((ComplicatedKeysAction) action).getKeyStrokesSet();
} else {
actionKeys = ((ComplicatedKeysAction)action).getKeyStrokesSet();
}
else {
throw new RuntimeException("Cannot register action: " + action.getClass().getName());
}
}
@ -262,8 +261,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
}
}
public static @NotNull
ShortcutSet toShortcutSet(@NotNull Collection<RequiredShortcut> requiredShortcuts) {
public static @NotNull ShortcutSet toShortcutSet(@NotNull Collection<RequiredShortcut> requiredShortcuts) {
final List<Shortcut> shortcuts = new ArrayList<>();
for (RequiredShortcut key : requiredShortcuts) {
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]));
}
private static @NotNull
List<Pair<EnumSet<MappingMode>, MappingInfo>> getKeyMappingRows(@NotNull Set<? extends MappingMode> modes) {
private static @NotNull List<Pair<EnumSet<MappingMode>, MappingInfo>> getKeyMappingRows(@NotNull Set<? extends MappingMode> modes) {
final Map<ImmutableList<KeyStroke>, EnumSet<MappingMode>> actualModes = new HashMap<>();
for (MappingMode mode : modes) {
final KeyMapping mapping = VimPlugin.getKey().getKeyMapping(mode);
@ -283,7 +280,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
if (value != null) {
newValue = value.clone();
newValue.add(mode);
} else {
}
else {
newValue = EnumSet.of(mode);
}
actualModes.put(key, newValue);
@ -306,22 +304,21 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
return rows;
}
private static @NotNull
@NonNls
String getModesStringCode(@NotNull Set<MappingMode> modes) {
private static @NotNull @NonNls String getModesStringCode(@NotNull Set<MappingMode> modes) {
if (modes.equals(MappingMode.NVO)) {
return "";
} else if (modes.contains(MappingMode.INSERT)) {
}
else if (modes.contains(MappingMode.INSERT)) {
return "i";
} else if (modes.contains(MappingMode.NORMAL)) {
}
else if (modes.contains(MappingMode.NORMAL)) {
return "n";
}
// TODO: Add more codes
return "";
}
private @NotNull
List<AnAction> getActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
private @NotNull List<AnAction> getActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
final List<AnAction> results = new ArrayList<>();
results.addAll(getLocalActions(component, keyStroke));
results.addAll(getKeymapActions(keyStroke));
@ -329,19 +326,17 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
}
@Override
public @NotNull
List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
return getActions(((IjVimEditor) editor).getEditor().getComponent(), keyStroke).stream()
public @NotNull List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
return getActions(((IjVimEditor)editor).getEditor().getComponent(), keyStroke).stream()
.map(IjNativeAction::new).collect(toList());
}
private static @NotNull
List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
private static @NotNull List<AnAction> getLocalActions(@NotNull Component component, @NotNull KeyStroke keyStroke) {
final List<AnAction> results = new ArrayList<>();
final KeyboardShortcut keyStrokeShortcut = new KeyboardShortcut(keyStroke, null);
for (Component c = component; c != null; c = c.getParent()) {
if (c instanceof JComponent) {
final List<AnAction> actions = ActionUtil.getActions((JComponent) c);
final List<AnAction> actions = ActionUtil.getActions((JComponent)c);
for (AnAction action : actions) {
if (action instanceof VimShortcutKeyAction) {
continue;
@ -358,8 +353,7 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
return results;
}
private static @NotNull
List<AnAction> getKeymapActions(@NotNull KeyStroke keyStroke) {
private static @NotNull List<AnAction> getKeymapActions(@NotNull KeyStroke keyStroke) {
final List<AnAction> results = new ArrayList<>();
final Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
for (String id : keymap.getActionIds(keyStroke)) {

View File

@ -59,7 +59,7 @@ public class MarkGroup {
@Nullable
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);
if (systemMark == null) {
return null;

View File

@ -387,8 +387,7 @@ internal class MotionGroup : VimMotionGroupBase() {
} else if (cmd.action is TextObjectActionHandler) {
val action = cmd.action as TextObjectActionHandler
val range =
action.getRange(editor.vim, caret.vim, IjEditorExecutionContext(context!!), cnt, raw, cmd.argument)
?: return null
action.getRange(editor.vim, caret.vim, IjEditorExecutionContext(context!!), cnt, raw, cmd.argument) ?: return null
start = range.startOffset
end = range.endOffset
if (cmd.isLinewiseMotion()) end--

View File

@ -57,7 +57,7 @@ public class ProcessGroup extends VimProcessGroupBase {
@Override
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;
}
@ -66,12 +66,11 @@ public class ProcessGroup extends VimProcessGroupBase {
String label = String.valueOf(leader);
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
public @NotNull
String endSearchCommand() {
public @NotNull String endSearchCommand() {
ExEntryPanel panel = ExEntryPanel.getInstance();
panel.deactivate(true);
@ -99,7 +98,8 @@ public class ProcessGroup extends VimProcessGroupBase {
panel.handleKey(stroke);
return true;
} else {
}
else {
VimStateMachine.getInstance(editor).popModes();
KeyHandler.getInstance().reset(editor);
return false;
@ -127,11 +127,13 @@ public class ProcessGroup extends VimProcessGroupBase {
if (logger.isDebugEnabled()) logger.debug("swing=" + SwingUtilities.isEventDispatchThread());
VimInjectorKt.getInjector().getVimscriptExecutor().execute(text, editor, context, skipHistory(editor), true, CommandLineVimLContext.INSTANCE);
} catch (ExException e) {
}
catch (ExException e) {
VimPlugin.showMessage(e.getMessage());
VimPlugin.indicateError();
res = false;
} catch (Exception bad) {
}
catch (Exception bad) {
ProcessGroup.logger.error(bad);
VimPlugin.indicateError();
res = false;
@ -160,15 +162,16 @@ public class ProcessGroup extends VimProcessGroupBase {
panel.activate(((IjVimEditor) editor).getEditor(), ((IjEditorExecutionContext) context).getContext(), ":", initText, 1);
}
private @NotNull
String getRange(Editor editor, @NotNull Command cmd) {
private @NotNull String getRange(Editor editor, @NotNull Command cmd) {
String initText = "";
if (VimStateMachine.getInstance(new IjVimEditor(editor)).getMode() == VimStateMachine.Mode.VISUAL) {
initText = "'<,'>";
} else if (cmd.getRawCount() > 0) {
}
else if (cmd.getRawCount() > 0) {
if (cmd.getCount() == 1) {
initText = ".";
} else {
}
else {
initText = ".,.+" + (cmd.getCount() - 1);
}
}
@ -176,8 +179,7 @@ public class ProcessGroup extends VimProcessGroupBase {
return initText;
}
public @Nullable
String executeCommand(@NotNull VimEditor editor, @NotNull String command, @Nullable CharSequence input, @Nullable String currentDirectoryPath)
public @Nullable String executeCommand(@NotNull VimEditor editor, @NotNull String command, @Nullable CharSequence input, @Nullable String currentDirectoryPath)
throws ExecutionException, ProcessCanceledException {
// 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'
final String escapedCommand = shellxquote.equals("(")
? doEscape(command, shellxescape, "^")
: command;
? doEscape(command, shellxescape, "^")
: command;
// Required for Win32+cmd.exe, defaults to "(". See :help 'shellxquote'
final String quotedCommand = shellxquote.equals("(")
? "(" + escapedCommand + ")"
: (shellxquote.equals("\"(")
? "\"(" + escapedCommand + ")\""
: shellxquote + escapedCommand + shellxquote);
? "(" + escapedCommand + ")"
: (shellxquote.equals("\"(")
? "\"(" + escapedCommand + ")\""
: shellxquote + escapedCommand + shellxquote);
final ArrayList<String> commands = new ArrayList<>();
commands.add(shell);
@ -229,7 +231,8 @@ public class ProcessGroup extends VimProcessGroupBase {
final BufferedWriter outputStreamWriter = new BufferedWriter(new OutputStreamWriter(handler.getProcessInput()));
copy(charSequenceReader, outputStreamWriter);
outputStreamWriter.close();
} catch (IOException e) {
}
catch (IOException e) {
logger.error(e);
}
}

View File

@ -57,7 +57,8 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
final Element textElement = new Element("text");
VimPlugin.getXML().setSafeXmlText(textElement, text);
registerElement.addContent(textElement);
} else {
}
else {
logger.trace("Save register as 'keys'");
final Element keys = new Element("keys");
final List<KeyStroke> list = register.getKeys();
@ -101,11 +102,13 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
if (text != null) {
logger.trace("Register data parsed");
register = new Register(key, type, text, Collections.emptyList());
} else {
}
else {
logger.trace("Cannot parse register data");
register = null;
}
} else {
}
else {
logger.trace("Register has 'keys' element");
final Element keysElement = registerElement.getChild("keys");
final List<Element> keyElements = keysElement.getChildren("key");
@ -113,11 +116,11 @@ public class RegisterGroup extends VimRegisterGroupBase implements PersistentSta
for (Element keyElement : keyElements) {
final int code = Integer.parseInt(keyElement.getAttributeValue("code"));
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
strokes.add(c == KeyEvent.CHAR_UNDEFINED ?
KeyStroke.getKeyStroke(code, modifiers) :
KeyStroke.getKeyStroke(c));
KeyStroke.getKeyStroke(code, modifiers) :
KeyStroke.getKeyStroke(c));
}
register = new Register(key, type, strokes);
}

View File

@ -110,18 +110,15 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
*
* @return The pattern used for last search. Can be null
*/
public @Nullable
String getLastSearchPattern() {
public @Nullable String getLastSearchPattern() {
return lastSearch;
}
/**
* Get the last pattern used in substitution.
*
* @return The pattern used for the last substitute command. Can be null
*/
public @Nullable
String getLastSubstitutePattern() {
public @Nullable String getLastSubstitutePattern() {
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
*/
public @Nullable
String getLastUsedPattern() {
public @Nullable String getLastUsedPattern() {
switch (lastPatternIdx) {
case RE_SEARCH:
return lastSearch;
case RE_SUBST:
return lastSubstitute;
case RE_SEARCH: return lastSearch;
case RE_SUBST: return lastSubstitute;
}
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>
*
* @param pattern The pattern to remember
* @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
* update the last used pattern index
* @param pattern The pattern to remember
* @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
* update the last used pattern index
*/
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
@ -189,10 +183,10 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
/**
* Sets the last search state, purely for tests
*
* @param editor The editor to update
* @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 direction The direction to search
* @param editor The editor to update
* @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 direction The direction to search
*/
@TestOnly
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
*
* @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
*
* @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()
public static @NotNull
List<TextRange> findAll(@NotNull Editor editor,
@NotNull String pattern,
int startLine,
int endLine,
boolean ignoreCase) {
public static @NotNull List<TextRange> findAll(@NotNull Editor editor,
@NotNull String pattern,
int startLine,
int endLine,
boolean 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.
* If the pattern is empty, the last used (search? substitute?) pattern (and offset?) is used.
* @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
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();
patternOffset = end.toString();
if (logger.isDebugEnabled()) logger.debug("Pattern contains offset " + patternOffset);
} else {
}
else {
logger.debug("no offset");
patternOffset = "";
}
} else if (command.length() == 1) {
}
else if (command.length() == 1) {
patternOffset = "";
} else {
}
else {
patternOffset = command.substring(1);
if (logger.isDebugEnabled()) logger.debug("offset=" + patternOffset);
}
@ -340,7 +337,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
resetShowSearchHighlight();
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 startOffset The offset to start searching from
* @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) {
@ -404,22 +401,22 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
*
* <p>Equivalent to normal.c:nv_ident</p>
*
* @param editor The editor to search in
* @param caret The caret to use to look for the current word
* @param count Search for the nth occurrence of the current word
* @param whole Include word boundaries in the search pattern
* @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
* @param editor The editor to search in
* @param caret The caret to use to look for the current word
* @param count Search for the nth occurrence of the current word
* @param whole Include word boundaries in the search pattern
* @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
*/
@Override
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) {
logger.warn("No range was found");
return -1;
}
@NotNull final Editor editor1 = ((IjVimEditor) editor).getEditor();
@NotNull final Editor editor1 = ((IjVimEditor)editor).getEditor();
final int start = range.getStartOffset();
final int end = range.getEndOffset();
final String pattern = SearchHelper.makeSearchPattern(
@ -437,7 +434,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
resetShowSearchHighlight();
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;
}
@ -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.
* E.g. `?foo` followed by `n` will search backwards. scanwrap and ignorecase come from options.</p>
*
* @param editor The editor to search in
* @param caret Used to get the offset to start searching from
* @param count Find the nth occurrence
* @return The offset of the next match, or -1 if not found
* @param editor The editor to search in
* @param caret Used to get the offset to start searching from
* @param count Find the nth occurrence
* @return The offset of the next match, or -1 if not found
*/
@Override
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.
* E.g. `?foo` followed by `N` will be forwards. scanwrap and ignorecase come from options.</p>
*
* @param editor The editor to search in
* @param caret Used to get the offset to starting searching from
* @param count Find the nth occurrence
* @return The offset of the next match, or -1 if not found
* @param editor The editor to search in
* @param caret Used to get the offset to starting searching from
* @param count Find the nth occurrence
* @return The offset of the next match, or -1 if not found
*/
@Override
public int searchPrevious(@NotNull VimEditor editor, @NotNull ImmutableVimCaret caret, int count) {
return searchNextWithDirection(((IjVimEditor) editor).getEditor(), ((IjVimCaret) caret).getCaret(), count,
lastDir.reverse());
return searchNextWithDirection(((IjVimEditor)editor).getEditor(), ((IjVimCaret)caret).getCaret(), count,
lastDir.reverse());
}
// See normal.c:nv_next
@ -508,12 +505,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
*
* <p>See ex_cmds.c:ex_substitute</p>
*
* @param editor The editor to search in
* @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 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]`
* @return True if the substitution succeeds, false on error. Will succeed even if nothing is modified
* @param editor The editor to search in
* @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 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]`
* @return True if the substitution succeeds, false on error. Will succeed even if nothing is modified
*/
@Override
@RWLockLabel.SelfSynchronized
@ -534,7 +531,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
int which_pat;
if ("~".equals(excmd)) {
which_pat = RE_LAST; /* use last used regexp */
} else {
}
else {
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 */
delimiter = cmd.charAt(); /* remember delimiter character */
cmd.inc();
} else {
}
else {
/* find the end of the regexp */
which_pat = RE_LAST; /* use last used regexp */
delimiter = cmd.charAt(); /* remember delimiter character */
@ -594,7 +593,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
}
cmd.inc();
}
} else {
}
else {
/* use previous pattern and substitution */
if (lastReplace == null) {
/* there is no previous command */
@ -610,7 +610,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
*/
if (cmd.charAt() == '&') {
cmd.inc();
} else {
}
else {
// :h :&& - "Note that :s and :& don't keep the flags"
do_all = options(injector, editor).isSet(OptionConstants.gdefault);
do_ask = false;
@ -624,20 +625,26 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
*/
if (cmd.charAt() == 'g') {
do_all = !do_all;
} else if (cmd.charAt() == 'c') {
}
else if (cmd.charAt() == 'c') {
do_ask = !do_ask;
} else if (cmd.charAt() == 'e') {
}
else if (cmd.charAt() == 'e') {
do_error = !do_error;
} else if (cmd.charAt() == 'r') {
}
else if (cmd.charAt() == 'r') {
/* use last used regexp */
which_pat = RE_LAST;
} else if (cmd.charAt() == 'i') {
}
else if (cmd.charAt() == 'i') {
/* ignore case */
do_ic = 'i';
} else if (cmd.charAt() == 'I') {
}
else if (cmd.charAt() == 'I') {
/* don't ignore case */
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 'n' to report number of matches without substituting
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,
RE_SUBST);
RE_SUBST);
if (!booleanregmmatch_tPair.getFirst()) {
if (do_error) {
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' */
if (do_ic == 'i') {
regmatch.rmm_ic = true;
} else if (do_ic == 'I') {
}
else if (do_ic == 'I') {
regmatch.rmm_ic = false;
}
@ -794,9 +802,9 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
caret.moveToOffset(startoff);
if (expression != null) {
try {
match = expression
.evaluate(editor, injector.getExecutionContextManager().onEditor(editor, null), parent)
.toInsertableString();
match = expression
.evaluate(editor, injector.getExecutionContextManager().onEditor(editor, null), parent)
.toInsertableString();
} catch (Exception e) {
exceptions.add((ExException) e);
match = "";
@ -805,7 +813,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
String finalMatch = match;
ApplicationManager.getApplication().runWriteAction(() -> ((IjVimEditor) editor).getEditor().getDocument().replaceString(startoff, endoff,
finalMatch));
finalMatch));
lastMatch = startoff;
int newend = startoff + match.length();
newpos = CharacterPosition.Companion.fromOffset(((IjVimEditor) editor).getEditor(), newend);
@ -822,14 +830,17 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
if (newpos != null) {
lnum = newpos.line;
searchcol = newpos.column;
} else {
}
else {
searchcol = endpos.column;
}
} else {
}
else {
searchcol = 0;
lnum++;
}
} else {
}
else {
lnum++;
searchcol = 0;
}
@ -839,7 +850,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
if (lastMatch != -1) {
caret.moveToOffset(
VimPlugin.getMotion().moveCaretToLineStartSkipLeading(editor, editor.offsetToBufferPosition(lastMatch).getLine()));
} else {
}
else {
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<Object, String, Object>> search_regcomp(CharPointer pat,
int which_pat,
int patSave) {
int which_pat,
int patSave) {
// 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.
boolean isNewPattern = true;
@ -910,7 +922,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
VimPlugin.showMessage(errorMessage);
return new Pair<>(false, null);
}
} else {
}
else {
pattern = pat.toString();
}
@ -932,8 +945,7 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
return new Pair<>(true, new Triple<>(regmatch, pattern, sp));
}
private static @NotNull
ReplaceConfirmationChoice confirmChoice(@NotNull Editor editor, @NotNull String match, @NotNull Caret caret, int startoff) {
private static @NotNull ReplaceConfirmationChoice confirmChoice(@NotNull Editor editor, @NotNull String match, @NotNull Caret caret, int startoff) {
final Ref<ReplaceConfirmationChoice> result = Ref.create(ReplaceConfirmationChoice.QUIT);
final Function1<KeyStroke, Boolean> keyStrokeProcessor = key -> {
final ReplaceConfirmationChoice choice;
@ -963,11 +975,12 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
break;
}
}
} else {
}
else {
// XXX: The Ex entry panel is used only for UI here, its logic might be inappropriate for this method
final ExEntryPanel exEntryPanel = ExEntryPanel.getInstanceWithoutShortcuts();
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);
ModalEntry.INSTANCE.activate(new IjVimEditor(editor), keyStrokeProcessor);
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
* update any other state. Direction is explicit, not from state.</p>
*
* @param editor The editor to search in
* @param count Find the nth occurrence
* @param forwards Search forwards or backwards
* @return The TextRange of the next occurrence or null if not found
* @param editor The editor to search in
* @param count Find the nth occurrence
* @param forwards Search forwards or backwards
* @return The TextRange of the next occurrence or null if not found
*/
@Override
public @Nullable
TextRange getNextSearchRange(@NotNull VimEditor editor, int count, boolean forwards) {
public @Nullable TextRange getNextSearchRange(@NotNull VimEditor editor, int count, boolean forwards) {
editor.removeSecondaryCarets();
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);
} else if (count > 1) {
}
else if (count > 1) {
current = findNextSearchForGn(editor, count - 1, forwards);
}
return current;
@ -1014,13 +1027,13 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
int currentPosition = editor.getCaretModel().getOffset();
if (forwards) {
return nextRange.getEndOffset() - VimPlugin.getVisualMotion().getSelectionAdj() == currentPosition;
} else {
}
else {
return nextRange.getStartOffset() == currentPosition;
}
}
private @Nullable
TextRange findNextSearchForGn(@NotNull VimEditor editor, int count, boolean forwards) {
private @Nullable TextRange findNextSearchForGn(@NotNull VimEditor editor, int count, boolean forwards) {
if (forwards) {
final EnumSet<SearchOptions> searchOptions = EnumSet.of(SearchOptions.WRAP, SearchOptions.WHOLE_FILE);
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);
if (foundBackward == null) return null;
int startOffset = foundBackward.getStartOffset() - 1;
if (startOffset < 0) startOffset = (int) editor.fileSize();
if (startOffset < 0) startOffset = (int)editor.fileSize();
searchOptions.remove(SearchOptions.BACKWARDS);
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();
@Contract(pure = true)
private DocumentSearchListener() {
private DocumentSearchListener () {
}
@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>
*
* @param editor The editor to search in
* @param startOffset The offset to search from
* @param count Find the nth occurrence
* @param dir The direction to search in
* @return The offset to the occurrence or -1 if not found
* @param editor The editor to search in
* @param startOffset The offset to search from
* @param count Find the nth occurrence
* @param dir The direction to search in
* @return The offset to the occurrence or -1 if not found
*/
private int findItOffset(@NotNull Editor editor, int startOffset, int count, Direction dir) {
boolean wrap = globalOptions(injector).isSet(OptionConstants.wrapscan);
@ -1271,7 +1284,8 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
// TODO: Don't move the caret!
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();
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;
if (lastPatternOffset.charAt(ppos + 1) == '/') {
nextDir = Direction.FORWARDS;
} else if (lastPatternOffset.charAt(ppos + 1) == '?') {
}
else if (lastPatternOffset.charAt(ppos + 1) == '?') {
nextDir = Direction.BACKWARDS;
} else {
}
else {
return res;
}
@ -1339,14 +1355,16 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
final String lastPatternText = getSafeChildText(search, "last-pattern");
if (lastPatternText == null || lastPatternText.equals(lastSearch)) {
lastPatternIdx = RE_SEARCH;
} else {
}
else {
lastPatternIdx = RE_SUBST;
}
Element dir = search.getChild("last-dir");
try {
lastDir = Direction.Companion.fromInt(Integer.parseInt(dir.getText()));
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
lastDir = Direction.FORWARDS;
}
@ -1359,15 +1377,13 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
}
}
private static @Nullable
String getSafeChildText(@NotNull Element element, @NotNull String name) {
private static @Nullable String getSafeChildText(@NotNull Element element, @NotNull String name) {
final Element child = element.getChild(name);
return child != null ? VimPlugin.getXML().getSafeXmlText(child) : null;
}
@SuppressWarnings("SameParameterValue")
private static @NotNull
String getSafeChildText(@NotNull Element element, @NotNull String name, @NotNull String defaultValue) {
private static @NotNull String getSafeChildText(@NotNull Element element, @NotNull String name, @NotNull String defaultValue) {
final Element child = element.getChild(name);
if (child != null) {
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
// 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
private @Nullable
String lastSearch; // Pattern used for last search command (`/`)
private @Nullable
String lastSubstitute; // Pattern used for last substitute command (`:s`)
private @Nullable String lastSearch; // Pattern used for last search command (`/`)
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 @Nullable
String lastReplace; // `# Last Substitute String` from viminfo
private @NotNull
String lastPatternOffset = ""; // /{pattern}/{offset}. Do not confuse with caret offset!
private @Nullable String lastReplace; // `# Last Substitute String` from viminfo
private @NotNull String lastPatternOffset = ""; // /{pattern}/{offset}. Do not confuse with caret offset!
private boolean lastIgnoreSmartCase;
private @NotNull
Direction lastDir = Direction.FORWARDS;
private @NotNull Direction lastDir = Direction.FORWARDS;
private boolean showSearchHighlight = globalOptions(injector).isSet(OptionConstants.hlsearch);
private boolean do_all = false; /* do multiple substitutions per line */

View File

@ -31,7 +31,6 @@ internal class VimJumpServiceImpl : VimJumpServiceBase(), PersistentStateCompone
companion object {
private val logger = vimLogger<VimJumpServiceImpl>()
}
override var lastJumpTimeStamp: Long = 0
override fun includeCurrentCommandAsNavigation(editor: VimEditor) {

View File

@ -37,7 +37,7 @@ import java.util.*;
public class WindowGroup extends WindowGroupBase {
@Override
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();
if (window != null) {
window.closeAllExcept(null);
@ -46,7 +46,7 @@ public class WindowGroup extends WindowGroupBase {
@Override
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();
for (final EditorWindow window : fileEditorManager.getWindows()) {
if (window != current) {
@ -61,7 +61,7 @@ public class WindowGroup extends WindowGroupBase {
@Override
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();
if (current != null) {
EditorWindow nextWindow = fileEditorManager.getNextWindow(current);
@ -73,7 +73,7 @@ public class WindowGroup extends WindowGroupBase {
@Override
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();
if (current != null) {
EditorWindow prevWindow = fileEditorManager.getPrevWindow(current);
@ -85,7 +85,7 @@ public class WindowGroup extends WindowGroupBase {
@Override
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();
if (index - 1 < windows.length) {
windows[index - 1].setAsCurrentWindow(true);
@ -94,12 +94,12 @@ public class WindowGroup extends WindowGroupBase {
@Override
public void splitWindowHorizontal(@NotNull ExecutionContext context, @NotNull String filename) {
splitWindow(SwingConstants.HORIZONTAL, (DataContext) context.getContext(), filename);
splitWindow(SwingConstants.HORIZONTAL, (DataContext)context.getContext(), filename);
}
@Override
public void splitWindowVertical(@NotNull ExecutionContext context, @NotNull String filename) {
splitWindow(SwingConstants.VERTICAL, (DataContext) context.getContext(), filename);
splitWindow(SwingConstants.VERTICAL, (DataContext)context.getContext(), filename);
}
@Override
@ -107,8 +107,8 @@ public class WindowGroup extends WindowGroupBase {
@RequiresReadLock
public void selectWindowInRow(@NotNull VimCaret caret, @NotNull ExecutionContext context, int relativePosition, boolean vertical) {
final Caret ijCaret = ((IjVimCaret) caret).getCaret();
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext) context.getContext()));
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
final FileEditorManagerEx fileEditorManager = getFileEditorManager(((DataContext)context.getContext()));
final EditorWindow currentWindow = fileEditorManager.getCurrentWindow();
if (currentWindow != null) {
final EditorWindow[] windows = fileEditorManager.getWindows();
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);
}
private static @NotNull
List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
@NotNull EditorWindow editorWindow,
@NotNull List<EditorWindow> windows, final boolean vertical) {
private static @NotNull List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
@NotNull EditorWindow editorWindow,
@NotNull List<EditorWindow> windows, final boolean vertical) {
final Point anchorPoint = getCaretPoint(caret);
if (anchorPoint != null) {
final List<EditorWindow> result = new ArrayList<>();
@ -156,8 +155,7 @@ public class WindowGroup extends WindowGroupBase {
return Collections.singletonList(editorWindow);
}
private static @NotNull
FileEditorManagerEx getFileEditorManager(@NotNull DataContext context) {
private static @NotNull FileEditorManagerEx getFileEditorManager(@NotNull DataContext context) {
final Project project = PlatformDataKeys.PROJECT.getData(context);
return FileEditorManagerEx.getInstanceEx(Objects.requireNonNull(project));
}
@ -182,8 +180,7 @@ public class WindowGroup extends WindowGroupBase {
}
}
private static @NotNull
Point getCaretPoint(@NotNull Caret caret) {
private static @NotNull Point getCaretPoint(@NotNull Caret caret) {
final Editor editor = caret.getEditor();
final Point caretLocation = editor.logicalPositionToXY(caret.getLogicalPosition());
Point caretScreenLocation = editor.getContentComponent().getLocationOnScreen();
@ -191,8 +188,7 @@ public class WindowGroup extends WindowGroupBase {
return caretScreenLocation;
}
private static @Nullable
Rectangle getSplitRectangle(@NotNull EditorWindow window) {
private static @Nullable Rectangle getSplitRectangle(@NotNull EditorWindow window) {
final EditorComposite editorComposite = window.getSelectedComposite();
if (editorComposite != null) {
final EditorTabbedContainer split = window.getTabbedPane();

View File

@ -42,8 +42,7 @@ public class EditorHelper {
// Code Vision)
private static final int BLOCK_INLAY_MAX_LINE_HEIGHT = 3;
public static @NotNull
Rectangle getVisibleArea(final @NotNull Editor editor) {
public static @NotNull Rectangle getVisibleArea(final @NotNull Editor editor) {
return editor.getScrollingModel().getVisibleAreaOnScrollingFinished();
}
@ -85,7 +84,7 @@ public class EditorHelper {
// (either because it's too short, or it's been scrolled up)
final Rectangle visibleArea = getVisibleArea(editor);
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) {
@ -156,7 +155,7 @@ public class EditorHelper {
* @return The number of screen columns
*/
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) {
final Rectangle area = getVisibleArea(editor);
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
* @return The matching editor or null if no match was found
*/
public static @Nullable
Editor getEditor(final @Nullable VirtualFile file) {
public static @Nullable Editor getEditor(final @Nullable VirtualFile file) {
if (file == null) {
return null;
}
@ -222,11 +220,10 @@ public class EditorHelper {
return null;
}
public static @NotNull
String pad(final @NotNull Editor editor,
@NotNull DataContext context,
int line,
final int to) {
public static @NotNull String pad(final @NotNull Editor editor,
@NotNull DataContext context,
int line,
final int to) {
final int len = EngineEditorHelperKt.lineLength(new IjVimEditor(editor), line);
if (len >= to) return "";
@ -239,8 +236,7 @@ public class EditorHelper {
*
* @param editor The editor from which the carets are taken
*/
public static @NotNull
List<Caret> getOrderedCaretsList(@NotNull Editor editor) {
public static @NotNull List<Caret> getOrderedCaretsList(@NotNull Editor editor) {
@NotNull List<Caret> carets = editor.getCaretModel().getAllCarets();
carets.sort(Comparator.comparingInt(Caret::getOffset));
@ -279,7 +275,8 @@ public class EditorHelper {
int inlayOffset = 0;
if (topInlayHeight > caretScreenOffset) {
inlayOffset = topInlayHeight;
} else if (bottomInlayHeight > visibleArea.height - caretScreenOffset + editor.getLineHeight()) {
}
else if (bottomInlayHeight > visibleArea.height - caretScreenOffset + editor.getLineHeight()) {
inlayOffset = -bottomInlayHeight;
}
@ -346,7 +343,8 @@ public class EditorHelper {
// screen
if (!allowVirtualSpace && offset > offsetForLastLineAtBottom) {
scrollVertically(editor, offsetForLastLineAtBottom);
} else {
}
else {
scrollVertically(editor, offset);
}
}
@ -397,7 +395,8 @@ public class EditorHelper {
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
if (inlay != null && inlay.isRelatedToPrecedingText()) {
targetVisualColumn = visualColumn + 1;
} else if (visualColumn > 0) {
}
else if (visualColumn > 0) {
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn - 1));
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
targetVisualColumn = visualColumn - 1;
@ -431,7 +430,8 @@ public class EditorHelper {
Inlay<?> inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn));
if (inlay != null && !inlay.isRelatedToPrecedingText()) {
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
// it is visible
inlay = editor.getInlayModel().getInlineElementAt(new VisualPosition(visualLine, visualColumn + 1));
@ -449,8 +449,8 @@ public class EditorHelper {
/**
* Scroll page down, moving text up.
*
* @param editor The editor to scroll
* @param pages How many pages to scroll
* @param editor The editor 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
*/
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 (i == pages - 1) {
caretVisualLine = lastVisualLine;
} else {
}
else {
@NotNull final VimEditor editor1 = new IjVimEditor(editor);
caretVisualLine = EngineEditorHelperKt.getVisualLineCount(editor1) - 1;
completed = false;
@ -500,8 +501,8 @@ public class EditorHelper {
/**
* Scroll page up, moving text down.
*
* @param editor The editor to scroll
* @param pages How many pages to scroll
* @param editor The editor 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
*/
public static Pair<Boolean, Integer> scrollFullPageUp(final @NotNull Editor editor, int pages) {
@ -523,7 +524,8 @@ public class EditorHelper {
if (targetBottomVisualLine == 1) {
completed = i == pages - 1;
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
// 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.
@ -549,7 +551,8 @@ public class EditorHelper {
int yActual = editor.visualLineToY(line);
if (yActual < topBound) {
line++;
} else if (yActual + editor.getLineHeight() > bottomBound) {
}
else if (yActual + editor.getLineHeight() > bottomBound) {
line--;
}
return line;
@ -580,7 +583,8 @@ public class EditorHelper {
}
return getPreviousNonInlayVisualPosition(editor, closestVisualPosition).column;
} else {
}
else {
return getNextNonInlayVisualPosition(editor, closestVisualPosition).column;
}
}
@ -613,8 +617,7 @@ public class EditorHelper {
* @param editor The editor
* @return The virtual file for the editor
*/
public static @Nullable
VirtualFile getVirtualFile(@NotNull Editor editor) {
public static @Nullable VirtualFile getVirtualFile(@NotNull Editor editor) {
return FileDocumentManager.getInstance().getFile(editor.getDocument());
}

View File

@ -21,41 +21,34 @@ import java.io.InputStreamReader;
* @author vlan
*/
public class MacKeyRepeat {
@VimNlsSafe
public static final String FMT = "defaults %s -globalDomain ApplePressAndHoldEnabled";
@NotNull
private static final MacKeyRepeat INSTANCE = new MacKeyRepeat();
@NonNls
private static final String EXEC_COMMAND = "launchctl stop com.apple.SystemUIServer.agent";
@NonNls
private static final String delete = "delete";
@NonNls
private static final String write = "write";
@NonNls
private static final String read = "read";
@VimNlsSafe public static final String FMT = "defaults %s -globalDomain ApplePressAndHoldEnabled";
@NotNull private static final MacKeyRepeat INSTANCE = new MacKeyRepeat();
@NonNls private static final String EXEC_COMMAND = "launchctl stop com.apple.SystemUIServer.agent";
@NonNls private static final String delete = "delete";
@NonNls private static final String write = "write";
@NonNls private static final String read = "read";
public static @NotNull
MacKeyRepeat getInstance() {
public static @NotNull MacKeyRepeat getInstance() {
return INSTANCE;
}
private static @NotNull
String read(@NotNull InputStream stream) throws IOException {
private static @NotNull String read(@NotNull InputStream stream) throws IOException {
return CharStreams.toString(new InputStreamReader(stream));
}
public @Nullable
Boolean isEnabled() {
public @Nullable Boolean isEnabled() {
final String command = String.format(FMT, read);
try {
final Process process = Runtime.getRuntime().exec(command);
final String data = read(process.getInputStream()).trim();
try {
return Integer.parseInt(data) == 0;
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
return null;
}
} catch (IOException e) {
}
catch (IOException e) {
return null;
}
}
@ -64,7 +57,8 @@ public class MacKeyRepeat {
final String command;
if (value == null) {
command = String.format(FMT, delete);
} else {
}
else {
final String arg = value ? "0" : "1";
command = String.format(FMT, write) + " " + arg;
}
@ -74,7 +68,8 @@ public class MacKeyRepeat {
defaults.waitFor();
final Process restartSystemUI = runtime.exec(EXEC_COMMAND);
restartSystemUI.waitFor();
} catch (IOException | InterruptedException ignored) {
}
catch (IOException | InterruptedException ignored) {
}
}
}

View File

@ -61,7 +61,8 @@ public class PsiHelper {
index = i;
if (count > 0) count--;
break;
} else if (navigationOffsets.get(i) == offset) {
}
else if (navigationOffsets.get(i) == offset) {
index = i;
break;
}
@ -69,7 +70,8 @@ public class PsiHelper {
int resultIndex = index + count;
if (resultIndex < 0) {
resultIndex = 0;
} else if (resultIndex >= navigationOffsets.size()) {
}
else if (resultIndex >= navigationOffsets.size()) {
resultIndex = navigationOffsets.size() - 1;
}
@ -80,7 +82,7 @@ public class PsiHelper {
@NotNull List<Integer> navigationOffsets,
boolean start) {
if (root instanceof PsiTreeElementBase) {
PsiElement element = ((PsiTreeElementBase<?>) root).getValue();
PsiElement element = ((PsiTreeElementBase<?>)root).getValue();
int offset;
if (start) {
offset = element.getTextRange().getStartOffset();
@ -93,7 +95,8 @@ public class PsiHelper {
offset += braceIndex;
}
}
} else {
}
else {
offset = element.getTextRange().getEndOffset() - 1;
}
if (!navigationOffsets.contains(offset)) {
@ -105,8 +108,7 @@ public class PsiHelper {
}
}
public static @Nullable
PsiFile getFile(@NotNull Editor editor) {
public static @Nullable PsiFile getFile(@NotNull Editor editor) {
VirtualFile vf = EditorHelper.getVirtualFile(editor);
if (vf != null) {
Project proj = editor.getProject();

File diff suppressed because it is too large Load Diff

View File

@ -79,11 +79,9 @@ internal var Caret.vimLastColumn: Int
_vimLastColumn = value
_vimLastColumnPos = visualPosition
}
internal fun Caret.resetVimLastColumn() {
_vimLastColumnPos = null
}
private var Caret._vimLastColumn: Int by userDataCaretToEditorOr { (this as Caret).inlayAwareVisualColumn }
private var Caret._vimLastColumnPos: VisualPosition? by userDataCaretToEditor()

View File

@ -15,17 +15,12 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public final class VimIcons {
public static final @NotNull
Icon IDEAVIM = load("/icons/ideavim.svg");
public static final @NotNull
Icon IDEAVIM_DISABLED = load("/icons/ideavim_disabled.svg");
public static final @NotNull
Icon TWITTER = load("/icons/twitter.svg");
public static final @NotNull
Icon YOUTRACK = load("/icons/youtrack.svg");
public static final @NotNull Icon IDEAVIM = load("/icons/ideavim.svg");
public static final @NotNull Icon IDEAVIM_DISABLED = load("/icons/ideavim_disabled.svg");
public static final @NotNull Icon TWITTER = load("/icons/twitter.svg");
public static final @NotNull Icon YOUTRACK = load("/icons/youtrack.svg");
private static @NotNull
Icon load(@NotNull @NonNls String path) {
private static @NotNull Icon load(@NotNull @NonNls String path) {
return IconManager.getInstance().getIcon(path, VimIcons.class);
}
}

View File

@ -72,8 +72,7 @@ internal object IdeaSpecifics {
val isVimAction = (action as? AnActionWrapper)?.delegate is VimShortcutKeyAction
if (!isVimAction && injector.globalOptions().isSet(IjOptionConstants.trackactionids)) {
if (action !is NotificationService.ActionIdNotifier.CopyActionId && action !is NotificationService.ActionIdNotifier.StopTracking) {
val id: String? = ActionManager.getInstance().getId(action)
?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
val id: String? = ActionManager.getInstance().getId(action) ?: (action.shortcutSet as? ProxyShortcutSet)?.actionId
VimPlugin.getNotifications(event.dataContext.getData(CommonDataKeys.PROJECT)).notifyActionId(id)
}
}

View File

@ -33,7 +33,8 @@ internal class IntellijMark(bookmark: LineBookmark, override val col: Int, proje
}
private fun getMark(): LineBookmark? =
getProject()?.let { project ->
getProject()?.let {
project ->
BookmarksManager.getInstance(project)?.getBookmark(BookmarkType.get(key)) as? LineBookmark
}

View File

@ -84,7 +84,6 @@ internal class IjVimCaret(val caret: Caret) : VimCaretBase() {
set(value) {
caret.vimLastColumn = value
}
override fun resetLastColumn() = caret.resetVimLastColumn()
override val selectionStart: Int
get() = caret.selectionStart

View File

@ -8,13 +8,13 @@
/**
* IdeaVim command index.
* <p>
* <p>
*
*
* 1. Insert mode
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |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-C| {@link com.maddyhome.idea.vim.action.change.insert.InsertExitModeAction}
@ -80,13 +80,13 @@
* |i_<F1>| IntelliJ help
* |i_<Insert>| IntelliJ editor toggle insert/replace
* |i_CTRL-X_index| TO BE IMPLEMENTED
* <p>
* <p>
*
*
* 2. Normal mode
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |CTRL-A| {@link com.maddyhome.idea.vim.action.change.change.number.ChangeNumberIncAction}
* |CTRL-B| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollPageUpAction}
* |CTRL-C| TO BE IMPLEMENTED
@ -241,18 +241,18 @@
* |<S-Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftHomeAction}
* |<S-End>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionShiftEndAction}
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
* <p>
* <p>
*
*
* 2.1. Text objects
* <p>
*
* Text object commands are listed in the visual mode section.
* <p>
* <p>
*
*
* 2.2. Window commands
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |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-K| {@link com.maddyhome.idea.vim.action.window.WindowUpAction}
* |CTRL-W_CTRL-L| {@link com.maddyhome.idea.vim.action.window.WindowRightAction}
* <p>
* <p>
*
*
* 2.3. Square bracket commands
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* |[_CTRL-D| TO BE IMPLEMENTED
@ -361,13 +361,13 @@
* |]s| TO BE IMPLEMENTED
* |]z| TO BE IMPLEMENTED
* |]}| {@link com.maddyhome.idea.vim.action.motion.text.MotionUnmatchedBraceCloseAction}
* <p>
* <p>
*
*
* 2.4. Commands starting with 'g'
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |g_CTRL-A| not applicable
* |g_CTRL-G| {@link com.maddyhome.idea.vim.action.file.FileGetLocationInfoAction}
* |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<Home>| {@link com.maddyhome.idea.vim.action.motion.leftright.MotionFirstScreenColumnAction}
* |g<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionUpNotLineWiseAction}
* <p>
* <p>
*
*
* 2.5. Commands starting with 'z'
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* |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}
* |z<Left>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnRightAction}
* |z<Right>| {@link com.maddyhome.idea.vim.action.motion.scroll.MotionScrollColumnLeftAction}
* <p>
* <p>
*
*
* 3. Visual mode
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |v_CTRL-\_CTRL-N| {@link com.maddyhome.idea.vim.action.motion.visual.VisualExitModeAction}
* |v_CTRL-\_CTRL-G| TO BE IMPLEMENTED
* |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.motion.mark.MotionGotoFileMarkAction}
* |v_'| {@link com.maddyhome.idea.vim.action.motion.mark.MotionGotoFileMarkLineAction}
* <p>
* <p>
*
*
* 4. Select mode
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* |<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}
* |<Right>| {@link com.maddyhome.idea.vim.action.motion.select.motion.SelectMotionRightAction}
* |<Up>| {@link com.maddyhome.idea.vim.action.motion.updown.MotionArrowUpAction}
* <p>
*
* 5. Command line editing
* <p>
*
* tag action
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |c_CTRL-A| TO BE IMPLEMENTED
* |c_CTRL-B| {@link javax.swing.text.DefaultEditorKit#beginLineAction}
* |c_CTRL-C| {@link com.maddyhome.idea.vim.ui.ex.CancelEntryAction}
@ -665,13 +665,13 @@
* |c_digraph| {char1} <BS> {char2}
* |c_wildchar| TO BE IMPLEMENTED
* |'cedit'| TO BE IMPLEMENTED
* <p>
* <p>
*
*
* 6. Ex commands
* <p>
*
* tag handler
* -------------------------------------------------------------------------------------------------------------------
* <p>
*
* |:map| {@link com.maddyhome.idea.vim.vimscript.model.commands.mapping.MapCommand}
* |:nmap| ...
* |:vmap| ...
@ -696,12 +696,12 @@
* |:delcommand| {@link com.maddyhome.idea.vim.vimscript.model.commands.DelCmdCommand}
* |:comclear| {@link com.maddyhome.idea.vim.vimscript.model.commands.CmdClearCommand}
* ...
* <p>
*
* The list of supported Ex commands is incomplete.
* <p>
* <p>
*
*
* A. Misc commands
* <p>
*
* tag handler
* -------------------------------------------------------------------------------------------------------------------
* |]b| {@link com.maddyhome.idea.vim.action.motion.text.MotionCamelEndLeftAction}
@ -710,8 +710,8 @@
* |[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.MotionSentenceNextEndAction}
* <p>
* <p>
*
*
* See also :help index.
*
* @author vlan

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,7 @@ internal class ShortcutConflictState : ApplicationUsagesCollector() {
}
private fun getHandlersForShortcut(shortcut: KeyStroke): List<HandledModes> {
val modes = VimPlugin.getKey().shortcutConflicts[shortcut]
?: return listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED)
val modes = VimPlugin.getKey().shortcutConflicts[shortcut] ?: return listOf(HandledModes.NORMAL_UNDEFINED, HandledModes.INSERT_UNDEFINED, HandledModes.VISUAL_AND_SELECT_UNDEFINED)
return when (modes) {
is ShortcutOwnerInfo.AllModes -> {

View File

@ -23,8 +23,7 @@ internal class VimscriptState : ApplicationUsagesCollector() {
return setOf(
VIMSCRIPT.metric(
SOURCED_FILES with sourcedFiles.size,
IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size
?: -1),
IDEAVIMRC_SIZE with (VimRcService.findIdeaVimRc()?.readLines()?.filter { !it.matches(Regex("\\s*\".*")) && it.isNotBlank() }?.size ?: -1),
EXTENSIONS_ENABLED_BY_SET with (PluginState.enabledExtensions - extensionsEnabledWithPlug).toList(),
EXTENSIONS_ENABLED_BY_PLUG with extensionsEnabledWithPlug.toList(),
IS_IDE_SPECIFIC_CONFIGURATION_USED with isIDESpecificConfigurationUsed,

View File

@ -44,25 +44,18 @@ import static com.maddyhome.idea.vim.api.VimInjectorKt.injector;
* This panel displays text in a <code>more</code> like window.
*/
public class ExOutputPanel extends JPanel {
private final @NotNull
Editor myEditor;
private final @NotNull Editor myEditor;
private final @NotNull
JLabel myLabel = new JLabel("more");
private final @NotNull
JTextArea myText = new JTextArea();
private final @NotNull
JScrollPane myScrollPane =
private final @NotNull JLabel myLabel = new JLabel("more");
private final @NotNull JTextArea myText = new JTextArea();
private final @NotNull JScrollPane myScrollPane =
new JBScrollPane(myText, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
private final @NotNull
ComponentAdapter myAdapter;
private final @NotNull ComponentAdapter myAdapter;
private boolean myAtEnd = false;
private int myLineHeight = 0;
private @Nullable
JComponent myOldGlass = null;
private @Nullable
LayoutManager myOldLayout = null;
private @Nullable JComponent myOldGlass = null;
private @Nullable LayoutManager myOldLayout = null;
private boolean myWasOpaque = false;
private boolean myActive = false;
@ -97,8 +90,7 @@ public class ExOutputPanel extends JPanel {
return UserDataManager.getVimMorePanel(editor) != null;
}
public static @NotNull
ExOutputPanel getInstance(@NotNull Editor editor) {
public static @NotNull ExOutputPanel getInstance(@NotNull Editor editor) {
ExOutputPanel panel = UserDataManager.getVimMorePanel(editor);
if (panel == null) {
panel = new ExOutputPanel(editor);
@ -191,7 +183,7 @@ public class ExOutputPanel extends JPanel {
*/
private void activate() {
JRootPane root = SwingUtilities.getRootPane(myEditor.getContentComponent());
myOldGlass = (JComponent) root.getGlassPane();
myOldGlass = (JComponent)root.getGlassPane();
if (myOldGlass != null) {
myOldLayout = myOldGlass.getLayout();
myWasOpaque = myOldGlass.isOpaque();
@ -228,13 +220,14 @@ public class ExOutputPanel extends JPanel {
private void scrollHalfPage() {
double sa = myScrollPane.getVerticalScrollBar().getVisibleAmount() / 2.0;
double offset = Math.ceil(sa / myLineHeight) * myLineHeight;
scrollOffset((int) offset);
scrollOffset((int)offset);
}
private void handleEnter() {
if (myAtEnd) {
close();
} else {
}
else {
scrollLine();
}
}
@ -250,10 +243,11 @@ public class ExOutputPanel extends JPanel {
myScrollPane.getVerticalScrollBar().setValue(val + more);
myScrollPane.getHorizontalScrollBar().setValue(0);
if (val + more >=
myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount()) {
myScrollPane.getVerticalScrollBar().getMaximum() - myScrollPane.getVerticalScrollBar().getVisibleAmount()) {
myAtEnd = true;
myLabel.setText(MessageHelper.message("hit.enter.or.type.command.to.continue"));
} else {
}
else {
myLabel.setText(MessageHelper.message("ex.output.panel.more"));
}
myLabel.setFont(UiHelper.selectFont(myLabel.getText()));
@ -269,14 +263,14 @@ public class ExOutputPanel extends JPanel {
int visLines = getSize().height / myLineHeight - 1;
int lines = Math.min(count, visLines);
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;
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
SwingUtilities.getRootPane(contentComponent).getGlassPane());
SwingUtilities.getRootPane(contentComponent).getGlassPane());
bounds.setLocation(pos);
setBounds(bounds);
@ -284,7 +278,8 @@ public class ExOutputPanel extends JPanel {
if (!globalOptions(injector).isSet(OptionConstants.more)) {
// FIX
scrollOffset(100000);
} else {
}
else {
scrollOffset(0);
}
}
@ -324,7 +319,8 @@ public class ExOutputPanel extends JPanel {
public void keyTyped(@NotNull KeyEvent e) {
if (myExOutputPanel.myAtEnd) {
myExOutputPanel.close(e);
} else {
}
else {
switch (e.getKeyChar()) {
case ' ':
myExOutputPanel.scrollPage();

View File

@ -89,7 +89,7 @@ public class ExDocument extends PlainDocument {
if (attribute instanceof AttributedString as) {
final Map<AttributedCharacterIterator.Attribute, Object> attributes = as.getIterator().getAttributes();
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);
}
}

View File

@ -145,7 +145,7 @@ public class ExEntryPanel extends JPanel {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
JRootPane root = SwingUtilities.getRootPane(parent);
if (root == null) return;
oldGlass = (JComponent) root.getGlassPane();
oldGlass = (JComponent)root.getGlassPane();
oldLayout = oldGlass.getLayout();
wasOpaque = oldGlass.isOpaque();
oldGlass.setLayout(null);
@ -203,7 +203,8 @@ public class ExEntryPanel extends JPanel {
}
entry.deactivate();
} finally {
}
finally {
// Make sure we hide the UI, especially if something goes wrong
if (!ApplicationManager.getApplication().isUnitTestMode()) {
@ -235,13 +236,12 @@ public class ExEntryPanel extends JPanel {
}
final ScrollingModel scrollingModel = editor.getScrollingModel();
if (scrollingModel.getHorizontalScrollOffset() != horizontalOffset ||
scrollingModel.getVerticalScrollOffset() != verticalOffset) {
scrollingModel.getVerticalScrollOffset() != verticalOffset) {
scrollingModel.scroll(horizontalOffset, verticalOffset);
}
}
private final @NotNull
DocumentListener fontListener = new DocumentAdapter() {
private final @NotNull DocumentListener fontListener = new DocumentAdapter() {
@Override
protected void textChanged(@NotNull DocumentEvent e) {
String text = entry.getActualText();
@ -252,8 +252,7 @@ public class ExEntryPanel extends JPanel {
}
};
private final @NotNull
DocumentListener incSearchDocumentListener = new DocumentAdapter() {
private final @NotNull DocumentListener incSearchDocumentListener = new DocumentAdapter() {
@Override
protected void textChanged(@NotNull DocumentEvent e) {
final Editor editor = entry.getEditor();
@ -297,15 +296,15 @@ public class ExEntryPanel extends JPanel {
final int matchOffset = SearchHighlightsHelper.updateIncsearchHighlights(editor, pattern, forwards, caretOffset, searchRange);
if (matchOffset != -1) {
new IjVimCaret(editor.getCaretModel().getPrimaryCaret()).moveToOffset(matchOffset);
} else {
}
else {
resetCaretOffset(editor);
}
}
}
@Contract("null -> null")
private @Nullable
Command getIncsearchCommand(@Nullable String commandText) {
private @Nullable Command getIncsearchCommand(@Nullable String commandText) {
if (commandText == null) return null;
try {
final Command exCommand = VimscriptParser.INSTANCE.parseCommand(commandText);
@ -313,7 +312,8 @@ public class ExEntryPanel extends JPanel {
if (exCommand instanceof SubstituteCommand) {
return exCommand;
}
} catch (Exception e) {
}
catch(Exception e) {
logger.warn("Cannot parse command for incsearch", e);
}
@ -353,13 +353,11 @@ public class ExEntryPanel extends JPanel {
*
* @return The user entered text
*/
public @NotNull
String getText() {
public @NotNull String getText() {
return entry.getActualText();
}
public @NotNull
ExTextField getEntry() {
public @NotNull ExTextField getEntry() {
return entry;
}
@ -412,7 +410,7 @@ public class ExEntryPanel extends JPanel {
if (parent == null) return;
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
int height = (int) getPreferredSize().getHeight();
int height = (int)getPreferredSize().getHeight();
if (scroll != null) {
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
@ -432,12 +430,9 @@ public class ExEntryPanel extends JPanel {
private int count;
// UI stuff
private @Nullable
JComponent parent;
private final @NotNull
JLabel label;
private final @NotNull
ExTextField entry;
private @Nullable JComponent parent;
private final @NotNull JLabel label;
private final @NotNull ExTextField entry;
private JComponent oldGlass;
private LayoutManager oldLayout;
private boolean wasOpaque;
@ -447,8 +442,7 @@ public class ExEntryPanel extends JPanel {
private int horizontalOffset;
private int caretOffset;
private final @NotNull
ComponentListener resizePanelListener = new ComponentAdapter() {
private final @NotNull ComponentListener resizePanelListener = new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
positionPanel();

View File

@ -47,8 +47,7 @@ import static java.lang.Math.*;
*/
public class ExTextField extends JTextField {
public static final @NonNls
String KEYMAP_NAME = "ex";
public static final @NonNls String KEYMAP_NAME = "ex";
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
* <p>
*
* Called whenever the text is changed, either by typing, or by special characters altering the text (e.g. Delete)
*/
void saveLastEntry() {
@ -162,7 +161,8 @@ public class ExTextField extends JTextField {
String txt;
if (i == history.size()) {
txt = lastEntry;
} else {
}
else {
HistoryEntry entry = history.get(i);
txt = entry.getEntry();
}
@ -176,12 +176,14 @@ public class ExTextField extends JTextField {
}
VimPlugin.indicateError();
} else {
}
else {
histIndex += dir;
String txt;
if (histIndex == history.size()) {
txt = lastEntry;
} else {
}
else {
HistoryEntry entry = history.get(histIndex);
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.
if (currentAction != null) {
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 :
(stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED),
(new Date()).getTime(), modifiers, keyCode, c);
@ -262,7 +265,7 @@ public class ExTextField extends JTextField {
useHandleKeyFromEx = false;
try {
super.processKeyEvent(event);
} finally {
}finally {
useHandleKeyFromEx = true;
}
}
@ -282,8 +285,7 @@ public class ExTextField extends JTextField {
* @return the default model implementation
*/
@Override
protected @NotNull
Document createDefaultModel() {
protected @NotNull Document createDefaultModel() {
return new ExDocument();
}
@ -293,7 +295,8 @@ public class ExTextField extends JTextField {
void escape() {
if (currentAction != null) {
clearCurrentAction();
} else {
}
else {
cancel();
}
}
@ -321,7 +324,7 @@ public class ExTextField extends JTextField {
/**
* 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
* 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.
@ -360,7 +363,7 @@ public class ExTextField extends JTextField {
}
private void setInsertMode() {
ExDocument doc = (ExDocument) getDocument();
ExDocument doc = (ExDocument)getDocument();
if (doc.isOverwrite()) {
doc.toggleInsertReplace();
}
@ -368,7 +371,7 @@ public class ExTextField extends JTextField {
}
void toggleInsertReplace() {
ExDocument doc = (ExDocument) getDocument();
ExDocument doc = (ExDocument)getDocument();
doc.toggleInsertReplace();
resetCaret();
}
@ -376,11 +379,13 @@ public class ExTextField extends JTextField {
private void resetCaret() {
if (getCaretPosition() == super.getText().length() || currentActionPromptCharacterOffset == super.getText().length() - 1) {
setNormalModeCaret();
} else {
ExDocument doc = (ExDocument) getDocument();
}
else {
ExDocument doc = (ExDocument)getDocument();
if (doc.isOverwrite()) {
setReplaceModeCaret();
} else {
}
else {
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()));
area.subtract(new Area(new Rectangle2D.Double(r.getX() + outlineThickness, r.getY() + outlineThickness, caretWidth - (2 * outlineThickness), r.getHeight() - (2 * outlineThickness))));
g2d.fill(area);
} else {
}
else {
final double caretHeight = getCaretHeight(r.getHeight());
final double caretWidth = getCaretWidth(fm, r.getX(), thickness);
g2d.fill(new Rectangle2D.Double(r.getX(), r.getY() + r.getHeight() - caretHeight, caretWidth, caretHeight));
}
} finally {
}
finally {
g2d.dispose();
}
}
/**
* 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().
*
* @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());
x = r.x;
y = r.y;
width = (int) ceil(getCaretWidth(fm, r.x, 100)) + 1;
width = (int)ceil(getCaretWidth(fm, r.x, 100)) + 1;
height = r.height;
repaint();
}
}
private @Nullable
Rectangle2D modelToView(int dot) {
private @Nullable Rectangle2D modelToView(int dot) {
if (dot > getComponent().getDocument().getLength()) {
return null;
}
try {
return getComponent().getUI().modelToView2D(getComponent(), dot, getDotBias());
} catch (BadLocationException e) {
}
catch (BadLocationException e) {
return null;
}
}
@ -532,13 +539,15 @@ public class ExTextField extends JTextField {
final Rectangle2D r = modelToView(getDot() + 1);
if (r != null) {
width = r.getX() - dotX;
} else {
}
else {
char c = ' ';
try {
if (getDot() < getComponent().getDocument().getLength()) {
c = getComponent().getText(getDot(), 1).charAt(0);
}
} catch (BadLocationException e) {
}
catch (BadLocationException e) {
// Ignore
}
width = fm.charWidth(c);
@ -556,8 +565,7 @@ public class ExTextField extends JTextField {
}
@TestOnly
public @NonNls
String getCaretShape() {
public @NonNls String getCaretShape() {
CommandLineCaret caret = (CommandLineCaret) getCaret();
return String.format("%s %d", caret.mode, caret.thickness);
}
@ -568,8 +576,7 @@ public class ExTextField extends JTextField {
private String actualText;
private List<HistoryEntry> history;
private int histIndex = 0;
private @Nullable
MultiStepAction currentAction;
private @Nullable MultiStepAction currentAction;
private char currentActionPromptCharacter;
private int currentActionPromptCharacterOffset = -1;

View File

@ -37,15 +37,11 @@ internal class GetFunctionHandler : FunctionHandler() {
return when (container) {
is VimList -> {
val idx = argumentValues[1].evaluate(editor, context, vimContext).asDouble().toInt()
container.values.getOrElse(idx) {
argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(-1)
}
container.values.getOrElse(idx) { argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(-1) }
}
is VimDictionary -> {
val key = argumentValues[1].evaluate(editor, context, vimContext).asString()
container.dictionary.getOrElse(VimString(key)) {
argumentValues.getOrNull(2)?.evaluate(editor, context, vimContext) ?: VimInt(0)
}
container.dictionary.getOrElse(VimString(key)) { 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")
else -> throw ExException("E896: Argument of get() must be a List, Dictionary or Blob")

View File

@ -29,7 +29,6 @@ internal object IdeaRefactorModeHelper {
fun keepMode() =
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_keep)
fun selectMode() =
injector.globalOptions().hasValue(IjOptionConstants.idearefactormode, IjOptionConstants.idearefactormode_select)

View File

@ -17,7 +17,6 @@ import org.antlr.v4.runtime.Recognizer
internal class IdeavimErrorListener : BaseErrorListener() {
private val logger = logger<IdeavimErrorListener>()
companion object {
val testLogger = mutableListOf<String>()
}

View File

@ -219,8 +219,7 @@ internal object ExpressionVisitor : VimscriptBaseVisitor<Expression>() {
}
override fun visitOptionExpression(ctx: OptionExpressionContext): Expression {
val result = OptionExpression(Scope.getByValue(ctx.option()?.text ?: "")
?: Scope.GLOBAL_VARIABLE, ctx.option().optionName().text)
val result = OptionExpression(Scope.getByValue(ctx.option()?.text ?: "") ?: Scope.GLOBAL_VARIABLE, ctx.option().optionName().text)
result.originalString = ctx.text
return result
}

View File

@ -602,7 +602,7 @@ class MotionActionTest : VimTestCase() {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-2733
// VIM-2733
@Test
fun testDeleteOuterQuoteEmptyString2() {
val keys = listOf("da'")
@ -653,7 +653,7 @@ class MotionActionTest : VimTestCase() {
doTest(keys, before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE)
}
// VIM-1427
// VIM-1427
@Test
fun testDeleteOuterTagWithCount() {
val keys = listOf("d2at")

View File

@ -23,7 +23,7 @@ zl Move the view on the text [count] characters to the
class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scrolls column to left`() {
fun`test scrolls column to left`() {
configureByColumns(200)
typeText("100|", "zl")
assertPosition(0, 99)
@ -32,7 +32,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scrolls column to left with zRight`() {
fun`test scrolls column to left with zRight`() {
configureByColumns(200)
typeText("100|", "z<Right>")
assertPosition(0, 99)
@ -41,7 +41,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scroll first column to left moves cursor`() {
fun`test scroll first column to left moves cursor`() {
configureByColumns(200)
typeText("100|", "zs", "zl")
assertPosition(0, 100)
@ -50,7 +50,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scrolls count columns to left`() {
fun`test scrolls count columns to left`() {
configureByColumns(200)
typeText("100|", "10zl")
assertPosition(0, 99)
@ -59,7 +59,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scrolls count columns to left with zRight`() {
fun`test scrolls count columns to left with zRight`() {
configureByColumns(200)
typeText("100|", "10z<Right>")
assertPosition(0, 99)
@ -68,7 +68,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scrolls column to left with sidescrolloff moves cursor`() {
fun`test scrolls column to left with sidescrolloff moves cursor`() {
configureByColumns(200)
enterCommand("set sidescrolloff=10")
typeText("100|", "zs", "zl")
@ -78,7 +78,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@Test
fun `test scroll column to left ignores sidescroll`() {
fun`test scroll column to left ignores sidescroll`() {
configureByColumns(200)
enterCommand("set sidescroll=10")
typeText("100|")
@ -95,7 +95,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@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)
typeText("200|", "ze", "zl")
assertPosition(0, 199)
@ -111,7 +111,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@VimBehaviorDiffers(description = "Vim has virtual space at end of line")
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@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)
typeText("200|", "ze", "50zl")
assertPosition(0, 199)
@ -122,7 +122,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@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)
addInlay(67, true, 5)
typeText("100|")
@ -136,7 +136,7 @@ class ScrollColumnLeftActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.DIFFERENT)
@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)
addInlay(67, false, 5)
typeText("100|")

View File

@ -23,7 +23,7 @@ zh Move the view on the text [count] characters to the
class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scrolls column to right`() {
fun`test scrolls column to right`() {
configureByColumns(200)
typeText("100|", "zh")
assertPosition(0, 99)
@ -32,7 +32,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scrolls column to right with zLeft`() {
fun`test scrolls column to right with zLeft`() {
configureByColumns(200)
typeText("100|", "z<Left>")
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")
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scroll last column to right moves cursor 1`() {
fun`test scroll last column to right moves cursor 1`() {
configureByColumns(200)
typeText("$")
// 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")
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scroll last column to right moves cursor 2`() {
fun`test scroll last column to right moves cursor 2`() {
configureByText(
buildString {
repeat(300) { append("0") }
@ -78,7 +78,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scrolls count columns to right`() {
fun`test scrolls count columns to right`() {
configureByColumns(200)
typeText("100|", "10zh")
assertPosition(0, 99)
@ -87,7 +87,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scrolls count columns to right with zLeft`() {
fun`test scrolls count columns to right with zLeft`() {
configureByColumns(200)
typeText("100|", "10z<Left>")
assertPosition(0, 99)
@ -96,7 +96,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scrolls column to right with sidescrolloff moves cursor`() {
fun`test scrolls column to right with sidescrolloff moves cursor`() {
configureByColumns(200)
enterCommand("set sidescrolloff=10")
typeText("100|", "ze", "zh")
@ -106,7 +106,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@Test
fun `test scroll column to right ignores sidescroll`() {
fun`test scroll column to right ignores sidescroll`() {
configureByColumns(200)
enterCommand("set sidescroll=10")
typeText("100|")
@ -122,7 +122,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@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)
typeText("10|", "zh")
assertPosition(0, 9)
@ -131,7 +131,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@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)
addInlay(130, true, 5)
typeText("100|")
@ -147,7 +147,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@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)
addInlay(130, false, 5)
typeText("100|")
@ -163,7 +163,7 @@ class ScrollColumnRightActionTest : VimTestCase() {
@TestWithoutNeovim(SkipNeovimReason.SCROLL)
@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)
addInlay(90, false, 5)
typeText("100|", "ze", "zh")

View File

@ -23,9 +23,9 @@ public class ActionLinkFixture extends ComponentFixture {
public void click() {
runJs("const offset = component.getHeight()/2;\n" +
"robot.click(" +
"component, " +
"new Point(offset, offset), " +
"MouseButton.LEFT_BUTTON, 1);");
"robot.click(" +
"component, " +
"new Point(offset, offset), " +
"MouseButton.LEFT_BUTTON, 1);");
}
}

View File

@ -45,7 +45,7 @@ class Editor(
get() = callJs("component.getEditor().getCaretModel().getOffset()", runInEdt = true)
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
get() = callJs("com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.hasBlockOrUnderscoreCaret(component.getEditor())", true)

View File

@ -33,6 +33,6 @@ public class WelcomeFrameFixture extends ContainerFixture {
public ComponentFixture importProjectLink() {
return find(ComponentFixture.class,
byXpath("//div[@accessiblename='Get from Version Control...' and @class='JButton']"));
byXpath("//div[@accessiblename='Get from Version Control...' and @class='JButton']"));
}
}

View File

@ -31,7 +31,6 @@ fun uiTest(testName: String = "test_${System.currentTimeMillis()}", url: String
throw e
}
}
private val client by lazy { OkHttpClient() }
private fun BufferedImage.save(name: String) {
val bytes = ByteArrayOutputStream().use { b ->

View File

@ -33,8 +33,7 @@ public class MotionShiftDownAction : ShiftedArrowKeyHandler(false) {
}
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
is Motion.NoMotion -> {
}
is Motion.NoMotion -> {}
is Motion.Error -> injector.messages.indicateError()
}
}

View File

@ -33,8 +33,7 @@ public class MotionShiftUpAction : ShiftedArrowKeyHandler(false) {
}
is Motion.AbsoluteOffset -> caret.moveToOffset(vertical.offset)
is Motion.NoMotion -> {
}
is Motion.NoMotion -> {}
is Motion.Error -> injector.messages.indicateError()
}
}

View File

@ -245,12 +245,10 @@ public fun VimEditor.getText(range: TextRange): String {
public fun VimEditor.getOffset(line: Int, column: Int): Int {
return bufferPositionToOffset(BufferPosition(line, column))
}
public fun VimEditor.getLineBuffer(line: Int): CharBuffer {
val start: Int = getLineStartOffset(line)
return CharBuffer.wrap(text(), start, start + getLineEndOffset(line, true) - getLineStartOffset(line))
}
public fun VimEditor.anyNonWhitespace(offset: Int, dir: Int): Boolean {
val start: Int
val end: Int

View File

@ -94,7 +94,6 @@ public interface VimChangeGroup {
operatorArguments: OperatorArguments,
saveToRegister: Boolean = true,
): Boolean
public fun changeCharacters(editor: VimEditor, caret: VimCaret, operatorArguments: OperatorArguments): Boolean
public fun changeEndOfLine(editor: VimEditor, caret: VimCaret, count: Int, operatorArguments: OperatorArguments): Boolean

View File

@ -178,8 +178,7 @@ public abstract class VimChangeGroupBase : VimChangeGroup {
val startOffsets = updatedRange.startOffsets
val endOffsets = updatedRange.endOffsets
for (i in updatedRange.size() - 1 downTo 0) {
val (newRange, _) = editor.search(startOffsets[i].offset to endOffsets[i].offset, editor, LineDeleteShift.NL_ON_END)
?: continue
val (newRange, _) = editor.search(startOffsets[i].offset to endOffsets[i].offset, editor, LineDeleteShift.NL_ON_END) ?: continue
editor.deleteString(TextRange(newRange.first.point, newRange.second.point))
}
if (type != null) {

View File

@ -16,7 +16,6 @@ public abstract class VimCommandGroupBase : VimCommandGroup {
public companion object {
private const val overridePrefix = "!"
}
private var aliases = HashMap<String, CommandAlias>()
override fun isAlias(command: String): Boolean {

View File

@ -84,265 +84,264 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
return true
}
private val defaultDigraphs = charArrayOf(
/*
'N', 'U', // 0 ^@
'S', 'H', // 1 ^A
'S', 'X', // 2 ^B
'E', 'X', // 3 ^C
'E', 'T', // 4 ^D
'E', 'Q', // 5 ^E
'A', 'K', // 6 ^F
'B', 'L', // 7 ^G
'B', 'S', // 8 ^H
'H', 'T', // 9 ^I
'L', 'F', // 10 ^J
'V', 'T', // 11 ^K
'F', 'F', // 12 ^L
'C', 'R', // 13 ^M
'S', 'O', // 14 ^N
'S', 'I', // 15 ^O
'D', 'L', // 16 ^P
'D', '1', // 17 ^Q
'D', '2', // 18 ^R
'D', '3', // 19 ^S
'D', '4', // 20 ^T
'N', 'K', // 21 ^U
'S', 'Y', // 22 ^V
'E', 'B', // 23 ^W
'C', 'N', // 24 ^X
'E', 'M', // 25 ^Y
'S', 'B', // 26 ^Z
'E', 'C', // 27 ^[
'F', 'S', // 28 ^\
'G', 'S', // 29 ^]
'R', 'S', // 30 ^^
'U', 'S', // 31 ^_
'S', 'P', // 32 Space
'\0', '\0', // 33 Unused
'\0', '\0', // 34 Unused
'N', 'b', // 35 #
'D', 'O', // 36 $
'\0', '\0', // 37 Unused
'\0', '\0', // 38 Unused
'\0', '\0', // 39 Unused
'\0', '\0', // 40 Unused
'\0', '\0', // 41 Unused
'\0', '\0', // 42 Unused
'\0', '\0', // 43 Unused
'\0', '\0', // 44 Unused
'\0', '\0', // 45 Unused
'\0', '\0', // 46 Unused
'\0', '\0', // 47 Unused
'\0', '\0', // 48 Unused
'\0', '\0', // 49 Unused
'\0', '\0', // 50 Unused
'\0', '\0', // 51 Unused
'\0', '\0', // 52 Unused
'\0', '\0', // 53 Unused
'\0', '\0', // 54 Unused
'\0', '\0', // 55 Unused
'\0', '\0', // 56 Unused
'\0', '\0', // 57 Unused
'\0', '\0', // 58 Unused
'\0', '\0', // 59 Unused
'\0', '\0', // 60 Unused
'\0', '\0', // 61 Unused
'\0', '\0', // 62 Unused
'\0', '\0', // 63 Unused
'A', 't', // 64 @
'\0', '\0', // 65 Unused
'\0', '\0', // 66 Unused
'\0', '\0', // 67 Unused
'\0', '\0', // 68 Unused
'\0', '\0', // 69 Unused
'\0', '\0', // 70 Unused
'\0', '\0', // 71 Unused
'\0', '\0', // 72 Unused
'\0', '\0', // 73 Unused
'\0', '\0', // 74 Unused
'\0', '\0', // 75 Unused
'\0', '\0', // 76 Unused
'\0', '\0', // 77 Unused
'\0', '\0', // 78 Unused
'\0', '\0', // 79 Unused
'\0', '\0', // 80 Unused
'\0', '\0', // 81 Unused
'\0', '\0', // 82 Unused
'\0', '\0', // 83 Unused
'\0', '\0', // 84 Unused
'\0', '\0', // 85 Unused
'\0', '\0', // 86 Unused
'\0', '\0', // 87 Unused
'\0', '\0', // 88 Unused
'\0', '\0', // 89 Unused
'\0', '\0', // 90 Unused
'<', '(', // 91 [
'/', '/', // 92 \
')', '>', // 93 ]
'\'', '>', // 94 ^
'\0', '\0', // 95 Unused
'\'', '!', // 96 `
'\0', '\0', // 97 Unused
'\0', '\0', // 98 Unused
'\0', '\0', // 99 Unused
'\0', '\0', // 100 Unused
'\0', '\0', // 101 Unused
'\0', '\0', // 102 Unused
'\0', '\0', // 103 Unused
'\0', '\0', // 104 Unused
'\0', '\0', // 105 Unused
'\0', '\0', // 106 Unused
'\0', '\0', // 107 Unused
'\0', '\0', // 108 Unused
'\0', '\0', // 109 Unused
'\0', '\0', // 110 Unused
'\0', '\0', // 111 Unused
'\0', '\0', // 112 Unused
'\0', '\0', // 113 Unused
'\0', '\0', // 114 Unused
'\0', '\0', // 115 Unused
'\0', '\0', // 116 Unused
'\0', '\0', // 117 Unused
'\0', '\0', // 118 Unused
'\0', '\0', // 119 Unused
'\0', '\0', // 120 Unused
'\0', '\0', // 121 Unused
'\0', '\0', // 122 Unused
'(', '!', // 123 {
'!', '!', // 124 |
'!', ')', // 125 }
'\'', '?', // 126 ~
'D', 'T', // 127 ^?
'P', 'A', // 128 ~@
'H', 'O', // 129 ~A
'B', 'H', // 130 ~B
'N', 'H', // 131 ~C
'I', 'N', // 132 ~D
'N', 'L', // 133 ~E
'S', 'A', // 134 ~F
'E', 'S', // 135 ~G
'H', 'S', // 136 ~H
'H', 'J', // 137 ~I
'V', 'S', // 138 ~J
'P', 'D', // 139 ~K
'P', 'U', // 140 ~L
'R', 'I', // 141 ~M
'S', '2', // 142 ~N
'S', '3', // 143 ~O
'D', 'C', // 144 ~P
'P', '1', // 145 ~Q
'P', '2', // 146 ~R
'T', 'S', // 147 ~S
'C', 'C', // 148 ~T
'M', 'W', // 149 ~U
'S', 'G', // 150 ~V
'E', 'G', // 151 ~W
'S', 'S', // 152 ~X
'G', 'C', // 153 ~Y
'S', 'C', // 154 ~Z
'C', 'I', // 155 ~[
'S', 'T', // 156 ~\
'O', 'C', // 157 ~]
'P', 'M', // 158 ~^
'A', 'C', // 159 ~_
'N', 'S', // 160 |
'!', 'I', // 161
'C', 't', // 162
'P', 'd', // 163
'C', 'u', // 164
'Y', 'e', // 165
'B', 'B', // 166
'S', 'E', // 167
'\'', ':', // 168
'C', 'o', // 169
'-', 'a', // 170
'<', '<', // 171
'N', 'O', // 172
'-', '-', // 173
'R', 'g', // 174
'\'', 'm', // 175
'D', 'G', // 176
'+', '-', // 177
'2', 'S', // 178
'3', 'S', // 179
'\'', '\'', // 180
'M', 'y', // 181
'P', 'I', // 182
'.', 'M', // 183
'\'', ',', // 184
'1', 'S', // 185
'-', 'o', // 186
'>', '>', // 187
'1', '4', // 188
'1', '2', // 189
'3', '4', // 190
'?', 'I', // 191
'A', '!', // 192
'A', '\'', // 193
'A', '>', // 194
'A', '?', // 195
'A', ':', // 196
'A', 'A', // 197
'A', 'E', // 198
'C', ',', // 199
'E', '!', // 200
'E', '\'', // 201
'E', '>', // 202
'E', ':', // 203
'I', '!', // 204
'I', '\'', // 205
'I', '>', // 206
'I', ':', // 207
'D', '-', // 208
'N', '?', // 209
'O', '!', // 210
'O', '\'', // 211
'O', '>', // 212
'O', '?', // 213
'O', ':', // 214
'*', 'X', // 215
'O', '/', // 216
'U', '!', // 217
'U', '\'', // 218
'U', '>', // 219
'U', ':', // 220
'Y', '\'', // 221
'T', 'H', // 222
's', 's', // 223
'a', '!', // 224
'a', '\'', // 225
'a', '>', // 226
'a', '?', // 227
'a', ':', // 228
'a', 'a', // 229
'a', 'e', // 230
'c', ',', // 231
'e', '!', // 232
'e', '\'', // 233
'e', '>', // 234
'e', ':', // 235
'i', '!', // 236
'i', '\'', // 237
'i', '>', // 238
'i', ':', // 239
'd', '-', // 240
'n', '?', // 241
'o', '!', // 242
'o', '\'', // 243
'o', '>', // 244
'o', '?', // 245
'o', ':', // 246
'-', ':', // 247
'o', '/', // 248
'u', '!', // 249
'u', '\'', // 250
'u', '>', // 251
'u', ':', // 252
'y', '\'', // 253
't', 'h', // 254
'y', ':', // 255
*/
private val defaultDigraphs = charArrayOf( /*
'N', 'U', // 0 ^@
'S', 'H', // 1 ^A
'S', 'X', // 2 ^B
'E', 'X', // 3 ^C
'E', 'T', // 4 ^D
'E', 'Q', // 5 ^E
'A', 'K', // 6 ^F
'B', 'L', // 7 ^G
'B', 'S', // 8 ^H
'H', 'T', // 9 ^I
'L', 'F', // 10 ^J
'V', 'T', // 11 ^K
'F', 'F', // 12 ^L
'C', 'R', // 13 ^M
'S', 'O', // 14 ^N
'S', 'I', // 15 ^O
'D', 'L', // 16 ^P
'D', '1', // 17 ^Q
'D', '2', // 18 ^R
'D', '3', // 19 ^S
'D', '4', // 20 ^T
'N', 'K', // 21 ^U
'S', 'Y', // 22 ^V
'E', 'B', // 23 ^W
'C', 'N', // 24 ^X
'E', 'M', // 25 ^Y
'S', 'B', // 26 ^Z
'E', 'C', // 27 ^[
'F', 'S', // 28 ^\
'G', 'S', // 29 ^]
'R', 'S', // 30 ^^
'U', 'S', // 31 ^_
'S', 'P', // 32 Space
'\0', '\0', // 33 Unused
'\0', '\0', // 34 Unused
'N', 'b', // 35 #
'D', 'O', // 36 $
'\0', '\0', // 37 Unused
'\0', '\0', // 38 Unused
'\0', '\0', // 39 Unused
'\0', '\0', // 40 Unused
'\0', '\0', // 41 Unused
'\0', '\0', // 42 Unused
'\0', '\0', // 43 Unused
'\0', '\0', // 44 Unused
'\0', '\0', // 45 Unused
'\0', '\0', // 46 Unused
'\0', '\0', // 47 Unused
'\0', '\0', // 48 Unused
'\0', '\0', // 49 Unused
'\0', '\0', // 50 Unused
'\0', '\0', // 51 Unused
'\0', '\0', // 52 Unused
'\0', '\0', // 53 Unused
'\0', '\0', // 54 Unused
'\0', '\0', // 55 Unused
'\0', '\0', // 56 Unused
'\0', '\0', // 57 Unused
'\0', '\0', // 58 Unused
'\0', '\0', // 59 Unused
'\0', '\0', // 60 Unused
'\0', '\0', // 61 Unused
'\0', '\0', // 62 Unused
'\0', '\0', // 63 Unused
'A', 't', // 64 @
'\0', '\0', // 65 Unused
'\0', '\0', // 66 Unused
'\0', '\0', // 67 Unused
'\0', '\0', // 68 Unused
'\0', '\0', // 69 Unused
'\0', '\0', // 70 Unused
'\0', '\0', // 71 Unused
'\0', '\0', // 72 Unused
'\0', '\0', // 73 Unused
'\0', '\0', // 74 Unused
'\0', '\0', // 75 Unused
'\0', '\0', // 76 Unused
'\0', '\0', // 77 Unused
'\0', '\0', // 78 Unused
'\0', '\0', // 79 Unused
'\0', '\0', // 80 Unused
'\0', '\0', // 81 Unused
'\0', '\0', // 82 Unused
'\0', '\0', // 83 Unused
'\0', '\0', // 84 Unused
'\0', '\0', // 85 Unused
'\0', '\0', // 86 Unused
'\0', '\0', // 87 Unused
'\0', '\0', // 88 Unused
'\0', '\0', // 89 Unused
'\0', '\0', // 90 Unused
'<', '(', // 91 [
'/', '/', // 92 \
')', '>', // 93 ]
'\'', '>', // 94 ^
'\0', '\0', // 95 Unused
'\'', '!', // 96 `
'\0', '\0', // 97 Unused
'\0', '\0', // 98 Unused
'\0', '\0', // 99 Unused
'\0', '\0', // 100 Unused
'\0', '\0', // 101 Unused
'\0', '\0', // 102 Unused
'\0', '\0', // 103 Unused
'\0', '\0', // 104 Unused
'\0', '\0', // 105 Unused
'\0', '\0', // 106 Unused
'\0', '\0', // 107 Unused
'\0', '\0', // 108 Unused
'\0', '\0', // 109 Unused
'\0', '\0', // 110 Unused
'\0', '\0', // 111 Unused
'\0', '\0', // 112 Unused
'\0', '\0', // 113 Unused
'\0', '\0', // 114 Unused
'\0', '\0', // 115 Unused
'\0', '\0', // 116 Unused
'\0', '\0', // 117 Unused
'\0', '\0', // 118 Unused
'\0', '\0', // 119 Unused
'\0', '\0', // 120 Unused
'\0', '\0', // 121 Unused
'\0', '\0', // 122 Unused
'(', '!', // 123 {
'!', '!', // 124 |
'!', ')', // 125 }
'\'', '?', // 126 ~
'D', 'T', // 127 ^?
'P', 'A', // 128 ~@
'H', 'O', // 129 ~A
'B', 'H', // 130 ~B
'N', 'H', // 131 ~C
'I', 'N', // 132 ~D
'N', 'L', // 133 ~E
'S', 'A', // 134 ~F
'E', 'S', // 135 ~G
'H', 'S', // 136 ~H
'H', 'J', // 137 ~I
'V', 'S', // 138 ~J
'P', 'D', // 139 ~K
'P', 'U', // 140 ~L
'R', 'I', // 141 ~M
'S', '2', // 142 ~N
'S', '3', // 143 ~O
'D', 'C', // 144 ~P
'P', '1', // 145 ~Q
'P', '2', // 146 ~R
'T', 'S', // 147 ~S
'C', 'C', // 148 ~T
'M', 'W', // 149 ~U
'S', 'G', // 150 ~V
'E', 'G', // 151 ~W
'S', 'S', // 152 ~X
'G', 'C', // 153 ~Y
'S', 'C', // 154 ~Z
'C', 'I', // 155 ~[
'S', 'T', // 156 ~\
'O', 'C', // 157 ~]
'P', 'M', // 158 ~^
'A', 'C', // 159 ~_
'N', 'S', // 160 |
'!', 'I', // 161
'C', 't', // 162
'P', 'd', // 163
'C', 'u', // 164
'Y', 'e', // 165
'B', 'B', // 166
'S', 'E', // 167
'\'', ':', // 168
'C', 'o', // 169
'-', 'a', // 170
'<', '<', // 171
'N', 'O', // 172
'-', '-', // 173
'R', 'g', // 174
'\'', 'm', // 175
'D', 'G', // 176
'+', '-', // 177
'2', 'S', // 178
'3', 'S', // 179
'\'', '\'', // 180
'M', 'y', // 181
'P', 'I', // 182
'.', 'M', // 183
'\'', ',', // 184
'1', 'S', // 185
'-', 'o', // 186
'>', '>', // 187
'1', '4', // 188
'1', '2', // 189
'3', '4', // 190
'?', 'I', // 191
'A', '!', // 192
'A', '\'', // 193
'A', '>', // 194
'A', '?', // 195
'A', ':', // 196
'A', 'A', // 197
'A', 'E', // 198
'C', ',', // 199
'E', '!', // 200
'E', '\'', // 201
'E', '>', // 202
'E', ':', // 203
'I', '!', // 204
'I', '\'', // 205
'I', '>', // 206
'I', ':', // 207
'D', '-', // 208
'N', '?', // 209
'O', '!', // 210
'O', '\'', // 211
'O', '>', // 212
'O', '?', // 213
'O', ':', // 214
'*', 'X', // 215
'O', '/', // 216
'U', '!', // 217
'U', '\'', // 218
'U', '>', // 219
'U', ':', // 220
'Y', '\'', // 221
'T', 'H', // 222
's', 's', // 223
'a', '!', // 224
'a', '\'', // 225
'a', '>', // 226
'a', '?', // 227
'a', ':', // 228
'a', 'a', // 229
'a', 'e', // 230
'c', ',', // 231
'e', '!', // 232
'e', '\'', // 233
'e', '>', // 234
'e', ':', // 235
'i', '!', // 236
'i', '\'', // 237
'i', '>', // 238
'i', ':', // 239
'd', '-', // 240
'n', '?', // 241
'o', '!', // 242
'o', '\'', // 243
'o', '>', // 244
'o', '?', // 245
'o', ':', // 246
'-', ':', // 247
'o', '/', // 248
'u', '!', // 249
'u', '\'', // 250
'u', '>', // 251
'u', ':', // 252
'y', '\'', // 253
't', 'h', // 254
'y', ':', // 255
*/
'N', 'U', '\u0000', // NULL (NUL)
'S', 'H', '\u0001', // START OF HEADING (SOH)
'S', 'X', '\u0002', // START OF TEXT (STX)

View File

@ -13,7 +13,6 @@ import com.maddyhome.idea.vim.mark.Jump
public abstract class VimJumpServiceBase : VimJumpService {
@JvmField
protected val jumps: MutableList<Jump> = ArrayList() // todo should it be mutable?
@JvmField
protected var jumpSpot: Int = -1

View File

@ -52,8 +52,7 @@ public abstract class VimOptionGroupBase : VimOptionGroup {
NumberOption(OptionConstants.scroll, "scr", 0),
NumberOption(OptionConstants.scrolloff, "so", 0),
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")
?: "sh"),
StringOption(OptionConstants.shell, "sh", if (injector.systemInfoService.isWindows) "cmd.exe" else System.getenv("SHELL") ?: "sh"),
StringOption(OptionConstants.shellxescape, "sxe", if (injector.systemInfoService.isWindows) "\"&|<>()@^" else "", isList = false),
ToggleOption(OptionConstants.showcmd, "sc", true),
ToggleOption(OptionConstants.showmode, "smd", true),

View File

@ -52,7 +52,7 @@ public interface VimSearchHelper {
*/
public fun findPreviousCamelStart(chars: CharSequence, endIndex: Int, count: Int): Int?
/**
/**
* @param chars the char sequence to search in
* @param startIndex the start index (inclusive)
* @param count search for the count-th occurrence

View File

@ -201,7 +201,6 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
}
return res
}
public fun findNextWordEnd(
chars: CharSequence,
pos: Int,

View File

@ -18,8 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
*/
public interface ExtensionHandler {
@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.

View File

@ -54,12 +54,8 @@ public sealed class ShortcutOwnerInfo {
owners[ShortcutOwner.IDE] = mutableListOf("a")
}
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy {
wights[it] ?: 1000
}.joinToString(separator = "-")
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy {
wights[it] ?: 1000
}.joinToString(separator = "-")
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
return if (ideOwners.isNotEmpty() && vimOwners.isNotEmpty()) {
ideOwners + ":" + ShortcutOwner.IDE.ownerName + " " + vimOwners + ":" + ShortcutOwner.VIM.ownerName

View File

@ -73,11 +73,11 @@ public object Magic {
public const val X: Int = 'X'.code - 256
public const val z: Int = 'z'.code - 256
/*
* Magic characters have a special meaning, they don't match literally.
* Magic characters are negative. This separates them from literal characters
* (possibly multi-byte). Only ASCII characters can be Magic.
*/
/*
* Magic characters have a special meaning, they don't match literally.
* Magic characters are negative. This separates them from literal characters
* (possibly multi-byte). Only ASCII characters can be Magic.
*/
public fun magic(x: Int): Int {
return x - 256
}

View File

@ -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 {
val actionName = argument.trim()
val action = injector.actionExecutor.getAction(actionName)
?: throw ExException(injector.messages.message("action.not.found.0", actionName))
val action = injector.actionExecutor.getAction(actionName) ?: throw ExException(injector.messages.message("action.not.found.0", actionName))
if (injector.application.isUnitTest()) {
executeAction(editor, action, context)
} else {

View File

@ -49,8 +49,7 @@ public class CallCommand(public val ranges: Ranges, public val functionCall: Exp
return ExecutionResult.Success
}
val name = (functionCall.scope?.toString()
?: "") + functionCall.functionName.evaluate(editor, context, vimContext)
val name = (functionCall.scope?.toString() ?: "") + functionCall.functionName.evaluate(editor, context, vimContext)
val funcref = injector.variableService.getNullableVariableValue(Variable(functionCall.scope, functionCall.functionName), editor, context, vimContext)
if (funcref is VimFuncref) {
funcref.handler.ranges = ranges

View File

@ -48,7 +48,6 @@ public data class CmdCommand(val ranges: Ranges, val argument: String) : Command
const val zeroOrOneArguments = "?"
const val moreThanZeroArguments = "+"
}
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val result: Boolean = if (argument.trim().isEmpty()) {
this.listAlias(editor, "")

View File

@ -53,7 +53,6 @@ public data class LetCommand(
private companion object {
private val logger = vimLogger<LetCommand>()
}
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
@Throws(ExException::class)

View File

@ -31,8 +31,7 @@ public data class PlugCommand(val ranges: Ranges, val argument: String) : Comman
return ExecutionResult.Error
}
injector.statisticsService.addExtensionEnabledWithPlug(injector.extensionRegistrator.getExtensionNameByAlias(pluginAlias)
?: "unknown extension")
injector.statisticsService.addExtensionEnabledWithPlug(injector.extensionRegistrator.getExtensionNameByAlias(pluginAlias) ?: "unknown extension")
return ExecutionResult.Success
}
}

View File

@ -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)
throw InvalidCommandException(message, null)
}
val parsedCommand = injector.vimscriptParser.parseCommand(commandAlias.command)
?: throw ExException("E492: Not an editor command: ${commandAlias.command}")
val parsedCommand = injector.vimscriptParser.parseCommand(commandAlias.command) ?: throw ExException("E492: Not an editor command: ${commandAlias.command}")
return if (parsedCommand is UnknownCommand) {
processPossiblyAliasCommand(commandAlias.command, editor, context, aliasCountdown - 1)
} else {

View File

@ -183,8 +183,7 @@ public data class MapCommand(val ranges: Ranges, val argument: String, val cmd:
}
return fromKeys?.let {
val toExpr = if (specialArguments.contains(EXPR)) {
injector.vimscriptParser.parseExpression(toKeysBuilder.toString().trim())
?: throw ExException("E15: Invalid expression: ${toKeysBuilder.toString().trim()}")
injector.vimscriptParser.parseExpression(toKeysBuilder.toString().trim()) ?: throw ExException("E15: Invalid expression: ${toKeysBuilder.toString().trim()}")
} else {
SimpleExpression(toKeysBuilder.toString().trimStart())
}

View File

@ -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.Error -> exceptionsCaught.add(ExException("unknown error occurred")) // todo
is ExecutionResult.Return -> returnValue = result.value
is ExecutionResult.Success -> {
}
is ExecutionResult.Success -> {}
}
} else {
// 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
break
}
is ExecutionResult.Success -> {
}
is ExecutionResult.Success -> {}
}
} catch (e: ExException) {
if (e is FinishException) {