mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-29 19:34:09 +02:00
parent
bf0fba9c58
commit
832c1c0be3
src
main/java/com/maddyhome/idea/vim
EventFacade.javaRegisterActions.javaVimPlugin.java
ex/vimscript
extension
group
ChangeGroup.javaDigraphGroup.javaEditorGroup.javaFileGroup.javaKeyGroup.javaMotionGroup.ktProcessGroup.javaRegisterGroup.javaSearchGroup.javaVimJumpServiceImpl.ktWindowGroup.java
helper
icons
listener
mark
newapi
package-info.javaregexp
statistic
ui
vimscript
model
parser
test/java/ui/utils
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
action/motion/updown
api
EngineEditorHelper.ktVimChangeGroup.ktVimChangeGroupBase.ktVimCommandGroupBase.ktVimDigraphGroupBase.ktVimJumpServiceBase.ktVimOptionGroupBase.ktVimSearchHelperBase.kt
extension
key
vimscript/model
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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() {
|
||||
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() {
|
||||
public static @NotNull RegisterGroup getRegister() {
|
||||
return ((RegisterGroup)VimInjectorKt.getInjector().getRegisterGroup());
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
FileGroup 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() {
|
||||
public static @NotNull ProcessGroup getProcess() {
|
||||
return ((ProcessGroup)VimInjectorKt.getInjector().getProcessGroup());
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
MacroGroup getMacro() {
|
||||
public static @NotNull MacroGroup getMacro() {
|
||||
return (MacroGroup)VimInjectorKt.getInjector().getMacro();
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
DigraphGroup getDigraph() {
|
||||
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() {
|
||||
public static @NotNull KeyGroup getKey() {
|
||||
return ((KeyGroup)VimInjectorKt.getInjector().getKeyGroup());
|
||||
}
|
||||
|
||||
public static @Nullable
|
||||
KeyGroup getKeyIfCreated() {
|
||||
public static @Nullable KeyGroup getKeyIfCreated() {
|
||||
return ((KeyGroup)ApplicationManager.getApplication().getServiceIfCreated(VimKeyGroup.class));
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
WindowGroup 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() {
|
||||
public static @NotNull VisualMotionGroup getVisualMotion() {
|
||||
return (VisualMotionGroup)VimInjectorKt.getInjector().getVisualMotionGroup();
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
YankGroupBase getYank() {
|
||||
public static @NotNull YankGroupBase getYank() {
|
||||
return (YankGroupBase)VimInjectorKt.getInjector().getYank();
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
PutGroup 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");
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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) {
|
||||
@ -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() {
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -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();
|
||||
@ -108,9 +107,9 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public @Nullable
|
||||
Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
|
||||
public @Nullable Pair<@NotNull TextRange, @NotNull SelectionType> getDeleteRangeAndType2(@NotNull VimEditor editor,
|
||||
@NotNull VimCaret caret,
|
||||
@NotNull ExecutionContext context,
|
||||
final @NotNull Argument argument,
|
||||
@ -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();
|
||||
@ -186,7 +186,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
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;
|
||||
@ -210,7 +211,8 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
|
||||
if (visualBlockMode || !append) {
|
||||
insertBeforeCursor(editor, context);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
insertAfterCursor(editor, context);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
@ -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,8 +640,7 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
strokes.add(chars);
|
||||
}
|
||||
|
||||
private @Nullable
|
||||
String changeNumberInRange(final @NotNull VimEditor editor,
|
||||
private @Nullable String changeNumberInRange(final @NotNull VimEditor editor,
|
||||
Pair<TextRange, NumberType> range,
|
||||
final int count,
|
||||
boolean alpha,
|
||||
@ -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();
|
||||
@ -742,5 +750,6 @@ public class ChangeGroup extends VimChangeGroupBase {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final Logger logger = Logger.getInstance(ChangeGroup.class.getName());
|
||||
}
|
||||
|
@ -42,10 +42,12 @@ public class DigraphGroup extends VimDigraphGroupBase {
|
||||
if (code < 32) {
|
||||
res.append('^');
|
||||
res.append((char)(code + '@'));
|
||||
} else if (code >= 128 && code <= 159) {
|
||||
}
|
||||
else if (code >= 128 && code <= 159) {
|
||||
res.append('~');
|
||||
res.append((char)(code - 128 + '@'));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res.append(code);
|
||||
res.append(' ');
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ import static com.maddyhome.idea.vim.helper.CaretVisualAttributesHelperKt.update
|
||||
*/
|
||||
@State(name = "VimEditorSettings", storages = {@Storage(value = "$APP_CONFIG$/vim_settings.xml")})
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
@ -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) {
|
||||
@ -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);
|
||||
@ -248,7 +250,8 @@ public class FileGroup extends VimFileBase {
|
||||
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,8 +269,7 @@ 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) {
|
||||
@ -322,7 +323,8 @@ 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(),
|
||||
@ -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());
|
||||
|
||||
@ -377,26 +380,30 @@ public class FileGroup extends VimFileBase {
|
||||
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("[+] ");
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
@ -56,12 +56,9 @@ import static java.util.stream.Collectors.toList;
|
||||
*/
|
||||
@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 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);
|
||||
@ -117,9 +114,11 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
||||
ShortcutOwnerInfo myValue = entry.getValue();
|
||||
if (myValue instanceof ShortcutOwnerInfo.AllModes) {
|
||||
owner = ((ShortcutOwnerInfo.AllModes)myValue).getOwner();
|
||||
} else if (myValue instanceof ShortcutOwnerInfo.PerMode) {
|
||||
}
|
||||
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<>();
|
||||
@ -227,7 +225,8 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
||||
final EditorActionHandlerBase action = actionHolder.getInstance();
|
||||
if (action instanceof ComplicatedKeysAction) {
|
||||
actionKeys = ((ComplicatedKeysAction)action).getKeyStrokesSet();
|
||||
} else {
|
||||
}
|
||||
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,14 +326,12 @@ public class KeyGroup extends VimKeyGroupBase implements PersistentStateComponen
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull
|
||||
List<NativeAction> getActions(@NotNull VimEditor editor, @NotNull KeyStroke keyStroke) {
|
||||
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()) {
|
||||
@ -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)) {
|
||||
|
@ -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--
|
||||
|
@ -70,8 +70,7 @@ public class ProcessGroup extends VimProcessGroupBase {
|
||||
}
|
||||
|
||||
@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
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
@ -213,17 +207,17 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
/**
|
||||
* Find all occurrences of the pattern
|
||||
*
|
||||
* @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 Use SearchHelper#findAll instead. Kept for compatibility with existing plugins
|
||||
*/
|
||||
@Deprecated()
|
||||
public static @NotNull
|
||||
List<TextRange> findAll(@NotNull Editor editor,
|
||||
public static @NotNull List<TextRange> findAll(@NotNull Editor editor,
|
||||
@NotNull String pattern,
|
||||
int startLine,
|
||||
int endLine,
|
||||
@ -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);
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
@ -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,7 +975,8 @@ 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);
|
||||
@ -997,14 +1010,14 @@ public class SearchGroup extends VimSearchGroupBase implements PersistentStateCo
|
||||
* @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)) {
|
||||
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);
|
||||
@ -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 */
|
||||
|
@ -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) {
|
||||
|
@ -124,8 +124,7 @@ public class WindowGroup extends WindowGroupBase {
|
||||
windows.get(normalized).setAsCurrentWindow(true);
|
||||
}
|
||||
|
||||
private static @NotNull
|
||||
List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
|
||||
private static @NotNull List<EditorWindow> findWindowsInRow(@NotNull Caret caret,
|
||||
@NotNull EditorWindow editorWindow,
|
||||
@NotNull List<EditorWindow> windows, final boolean vertical) {
|
||||
final Point anchorPoint = getCaretPoint(caret);
|
||||
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
@ -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,8 +220,7 @@ public class EditorHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
String pad(final @NotNull Editor editor,
|
||||
public static @NotNull String pad(final @NotNull Editor editor,
|
||||
@NotNull DataContext context,
|
||||
int line,
|
||||
final int to) {
|
||||
@ -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));
|
||||
@ -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;
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
@ -146,7 +146,8 @@ public class SearchHelper {
|
||||
if (dir == Direction.BACKWARDS && start_pos.col == 0) {
|
||||
lnum = pos.lnum - 1;
|
||||
at_first_line = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lnum = pos.lnum;
|
||||
}
|
||||
|
||||
@ -230,7 +231,8 @@ public class SearchHelper {
|
||||
match_ok = true;
|
||||
matchpos = new RegExp.lpos_T(regmatch.startpos[0]);
|
||||
endpos = new RegExp.lpos_T(regmatch.endpos[0]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -308,7 +310,8 @@ public class SearchHelper {
|
||||
lnum = lineCount - 1;
|
||||
//if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
|
||||
// give_warning((char_u *)_(top_bot_msg), TRUE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lnum = 0;
|
||||
//if (!shortmess(SHM_SEARCH) && (options & SEARCH_MSG))
|
||||
// give_warning((char_u *)_(bot_top_msg), TRUE);
|
||||
@ -324,9 +327,11 @@ public class SearchHelper {
|
||||
if (searchOptions.contains(SearchOptions.SHOW_MESSAGES)) {
|
||||
if (searchOptions.contains(SearchOptions.WRAP)) {
|
||||
VimPlugin.showMessage(MessageHelper.message(Msg.e_patnotf2, pattern));
|
||||
} else if (lnum <= 0) {
|
||||
}
|
||||
else if (lnum <= 0) {
|
||||
VimPlugin.showMessage(MessageHelper.message(Msg.E384, pattern));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
VimPlugin.showMessage(MessageHelper.message(Msg.E385, pattern));
|
||||
}
|
||||
}
|
||||
@ -351,8 +356,7 @@ public class SearchHelper {
|
||||
* @param ignoreCase Case sensitive or insensitive searching
|
||||
* @return A list of TextRange objects representing the results
|
||||
*/
|
||||
public static @NotNull
|
||||
List<TextRange> findAll(@NotNull Editor editor,
|
||||
public static @NotNull List<TextRange> findAll(@NotNull Editor editor,
|
||||
@NotNull String pattern,
|
||||
int startLine,
|
||||
int endLine,
|
||||
@ -385,11 +389,13 @@ public class SearchHelper {
|
||||
if (start != end) {
|
||||
line += matchedLines - 1;
|
||||
col = endPos.column;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line += matchedLines;
|
||||
col = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
line++;
|
||||
col = 0;
|
||||
}
|
||||
@ -440,8 +446,7 @@ public class SearchHelper {
|
||||
return findBlockLocation(chars, found, match, dir, pos, count, false);
|
||||
}
|
||||
|
||||
public static @Nullable
|
||||
TextRange findBlockRange(@NotNull Editor editor,
|
||||
public static @Nullable TextRange findBlockRange(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
char type,
|
||||
int count,
|
||||
@ -540,7 +545,8 @@ public class SearchHelper {
|
||||
|
||||
if (allWhite) {
|
||||
bend = o - 2;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
bend--;
|
||||
}
|
||||
}
|
||||
@ -560,7 +566,8 @@ public class SearchHelper {
|
||||
final int endOffset = comment.getTextOffset() + comment.getTextLength();
|
||||
if (pos < comment.getTextOffset() + prefix.length()) {
|
||||
return endOffset;
|
||||
} else if (pos >= endOffset - suffix.length()) {
|
||||
}
|
||||
else if (pos >= endOffset - suffix.length()) {
|
||||
return comment.getTextOffset();
|
||||
}
|
||||
}
|
||||
@ -692,7 +699,8 @@ public class SearchHelper {
|
||||
else if (c == '\n') {
|
||||
inString = false;
|
||||
inChar = false;
|
||||
} else if (pos != initialPos) {
|
||||
}
|
||||
else if (pos != initialPos) {
|
||||
// We found another character like our original - belongs to another pair
|
||||
if (!inString && !inChar && c == found) {
|
||||
stack++;
|
||||
@ -700,7 +708,8 @@ public class SearchHelper {
|
||||
// We found the start/end of a string
|
||||
else if (!inChar) {
|
||||
inString = checkInString(chars, inCheckPosF.apply(pos), true);
|
||||
} else if (!inString) {
|
||||
}
|
||||
else if (!inString) {
|
||||
inChar = checkInString(chars, inCheckPosF.apply(pos), false);
|
||||
}
|
||||
}
|
||||
@ -723,8 +732,7 @@ public class SearchHelper {
|
||||
return backslashCounter % 2 == 0;
|
||||
}
|
||||
|
||||
public static @Nullable
|
||||
Pair<Character, Integer> findPositionOfFirstCharacter(@NotNull CharSequence chars,
|
||||
public static @Nullable Pair<Character, Integer> findPositionOfFirstCharacter(@NotNull CharSequence chars,
|
||||
int pos,
|
||||
final Set<Character> needles,
|
||||
boolean searchEscaped,
|
||||
@ -768,8 +776,7 @@ public class SearchHelper {
|
||||
}
|
||||
|
||||
|
||||
public static @Nullable
|
||||
TextRange findBlockTagRange(@NotNull Editor editor,
|
||||
public static @Nullable TextRange findBlockTagRange(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
int count,
|
||||
boolean isOuter) {
|
||||
@ -786,7 +793,8 @@ public class SearchHelper {
|
||||
final int line = caret.getLogicalPosition().line;
|
||||
final int lineBegin = editor.getDocument().getLineStartOffset(line);
|
||||
searchStartPosition = ignoreWhitespaceAtLineStart(sequence, lineBegin, position);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
searchStartPosition = selectionEnd;
|
||||
}
|
||||
|
||||
@ -795,7 +803,8 @@ public class SearchHelper {
|
||||
while (searchStartPosition < sequence.length() && sequence.charAt(searchStartPosition) != '>') {
|
||||
searchStartPosition++;
|
||||
}
|
||||
} else if (isInHTMLTag(sequence, searchStartPosition, true)) {
|
||||
}
|
||||
else if (isInHTMLTag(sequence, searchStartPosition, true)) {
|
||||
// caret is inside closing tag. Move to starting '<'.
|
||||
while (searchStartPosition > 0 && sequence.charAt(searchStartPosition) != '<') {
|
||||
searchStartPosition--;
|
||||
@ -835,7 +844,8 @@ public class SearchHelper {
|
||||
// Special case: if the inner tag is already selected we should like isOuter is active
|
||||
// Note that we need to ignore newlines, because their selection is lost between multiple "it" invocations
|
||||
isOuter = true;
|
||||
} else if (openingTag.getEndOffset() == closingTagTextRange.getStartOffset() &&
|
||||
}
|
||||
else if (openingTag.getEndOffset() == closingTagTextRange.getStartOffset() &&
|
||||
selectionStart == openingTag.getEndOffset()) {
|
||||
// Special case: for an empty tag pair (e.g. <a></a>) the whole tag is selected if the caret is in the middle.
|
||||
isOuter = true;
|
||||
@ -844,7 +854,8 @@ public class SearchHelper {
|
||||
|
||||
if (isOuter) {
|
||||
return new TextRange(openingTag.getStartOffset(), closingTagTextRange.getEndOffset());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return new TextRange(openingTag.getEndOffset(), closingTagTextRange.getStartOffset());
|
||||
}
|
||||
}
|
||||
@ -885,8 +896,7 @@ public class SearchHelper {
|
||||
return closingBracket != -1 && sequence.charAt(closingBracket - 1) != '/';
|
||||
}
|
||||
|
||||
private static @Nullable
|
||||
Pair<TextRange, String> findUnmatchedClosingTag(final @NotNull CharSequence sequence,
|
||||
private static @Nullable Pair<TextRange, String> findUnmatchedClosingTag(final @NotNull CharSequence sequence,
|
||||
final int position,
|
||||
int count) {
|
||||
// The tag name may contain any characters except slashes, whitespace and '>'
|
||||
@ -910,13 +920,16 @@ public class SearchHelper {
|
||||
if (openTags.isEmpty()) {
|
||||
if (count <= 1) {
|
||||
return new Pair<>(new TextRange(position + matcher.start(), position + matcher.end()), tagName);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
count--;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
openTags.pop();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final String tagName = matcher.group(1);
|
||||
openTags.push(tagName);
|
||||
}
|
||||
@ -924,8 +937,7 @@ public class SearchHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static @Nullable
|
||||
TextRange findUnmatchedOpeningTag(@NotNull CharSequence sequence,
|
||||
private static @Nullable TextRange findUnmatchedOpeningTag(@NotNull CharSequence sequence,
|
||||
int position,
|
||||
@NotNull String tagName) {
|
||||
final String quotedTagName = Pattern.quote(tagName);
|
||||
@ -950,14 +962,16 @@ public class SearchHelper {
|
||||
if (!openTags.isEmpty()) {
|
||||
openTags.pop();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
openTags.push(match);
|
||||
}
|
||||
}
|
||||
|
||||
if (openTags.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return openTags.pop();
|
||||
}
|
||||
}
|
||||
@ -965,8 +979,7 @@ public class SearchHelper {
|
||||
/**
|
||||
* This counts all the words in the file.
|
||||
*/
|
||||
public static @NotNull
|
||||
CountPosition countWords(@NotNull Editor editor) {
|
||||
public static @NotNull CountPosition countWords(@NotNull Editor editor) {
|
||||
int size = EditorHelperRt.getFileSize(editor);
|
||||
|
||||
return countWords(editor, 0, size);
|
||||
@ -975,16 +988,14 @@ public class SearchHelper {
|
||||
/**
|
||||
* This counts all the words in the file.
|
||||
*/
|
||||
public static @NotNull
|
||||
CountPosition countWords(@NotNull Editor editor, int start, int end) {
|
||||
public static @NotNull CountPosition countWords(@NotNull Editor editor, int start, int end) {
|
||||
CharSequence chars = editor.getDocument().getCharsSequence();
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
return countWords(chars, start, end, offset);
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
CountPosition countWords(@NotNull CharSequence chars, int start, int end, int offset) {
|
||||
public static @NotNull CountPosition countWords(@NotNull CharSequence chars, int start, int end, int offset) {
|
||||
int count = 1;
|
||||
int position = 0;
|
||||
int last = -1;
|
||||
@ -999,10 +1010,12 @@ public class SearchHelper {
|
||||
|
||||
if (res == offset) {
|
||||
position = count;
|
||||
} else if (last < offset && res >= offset) {
|
||||
}
|
||||
else if (last < offset && res >= offset) {
|
||||
if (count == 2) {
|
||||
position = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
position = count - 1;
|
||||
}
|
||||
}
|
||||
@ -1017,8 +1030,7 @@ public class SearchHelper {
|
||||
return new CountPosition(count, position);
|
||||
}
|
||||
|
||||
public static @NotNull
|
||||
List<Pair<TextRange, NumberType>> findNumbersInRange(final @NotNull Editor editor,
|
||||
public static @NotNull List<Pair<TextRange, NumberType>> findNumbersInRange(final @NotNull Editor editor,
|
||||
@NotNull TextRange textRange,
|
||||
final boolean alpha,
|
||||
final boolean hex,
|
||||
@ -1070,8 +1082,7 @@ public class SearchHelper {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static @Nullable
|
||||
Pair<TextRange, NumberType> findNumberUnderCursor(final @NotNull Editor editor,
|
||||
public static @Nullable Pair<TextRange, NumberType> findNumberUnderCursor(final @NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
final boolean alpha,
|
||||
final boolean hex,
|
||||
@ -1098,8 +1109,7 @@ public class SearchHelper {
|
||||
* @param startPosOnLine - start offset to search
|
||||
* @return - text range with number
|
||||
*/
|
||||
public static @Nullable
|
||||
Pair<TextRange, NumberType> findNumberInText(final @NotNull String textInRange,
|
||||
public static @Nullable Pair<TextRange, NumberType> findNumberInText(final @NotNull String textInRange,
|
||||
int startPosOnLine,
|
||||
final boolean alpha,
|
||||
final boolean hex,
|
||||
@ -1132,7 +1142,8 @@ public class SearchHelper {
|
||||
pos < lineEndOffset - 1 &&
|
||||
"xX".indexOf(textInRange.charAt(pos + 1)) >= 0) {
|
||||
pos += 2;
|
||||
} else if ("xX".indexOf(textInRange.charAt(pos)) >= 0 && pos > 0 && textInRange.charAt(pos - 1) == '0') {
|
||||
}
|
||||
else if ("xX".indexOf(textInRange.charAt(pos)) >= 0 && pos > 0 && textInRange.charAt(pos - 1) == '0') {
|
||||
pos++;
|
||||
}
|
||||
|
||||
@ -1149,10 +1160,12 @@ public class SearchHelper {
|
||||
|
||||
if (!isHexChar || alpha) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pos++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1195,8 +1208,7 @@ public class SearchHelper {
|
||||
/**
|
||||
* Searches for digits block that matches parameters
|
||||
*/
|
||||
private static @NotNull
|
||||
Pair<Integer, Integer> findRange(final @NotNull String text,
|
||||
private static @NotNull Pair<Integer, Integer> findRange(final @NotNull String text,
|
||||
final int pos,
|
||||
final boolean alpha,
|
||||
final boolean hex,
|
||||
@ -1228,11 +1240,14 @@ public class SearchHelper {
|
||||
private static boolean isNumberChar(char ch, boolean alpha, boolean hex, boolean octal, boolean decimal) {
|
||||
if (alpha && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) {
|
||||
return true;
|
||||
} else if (octal && (ch >= '0' && ch <= '7')) {
|
||||
}
|
||||
else if (octal && (ch >= '0' && ch <= '7')) {
|
||||
return true;
|
||||
} else if (hex && ((ch >= '0' && ch <= '9') || "abcdefABCDEF".indexOf(ch) >= 0)) {
|
||||
}
|
||||
else if (hex && ((ch >= '0' && ch <= '9') || "abcdefABCDEF".indexOf(ch) >= 0)) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return decimal && (ch >= '0' && ch <= '9');
|
||||
}
|
||||
|
||||
@ -1245,8 +1260,7 @@ public class SearchHelper {
|
||||
* @param caret The caret to find word under
|
||||
* @return The text range of the found word or null if there is no word under/after the cursor on the line
|
||||
*/
|
||||
public static @Nullable
|
||||
TextRange findWordUnderCursor(@NotNull Editor editor, @NotNull Caret caret) {
|
||||
public static @Nullable TextRange findWordUnderCursor(@NotNull Editor editor, @NotNull Caret caret) {
|
||||
CharSequence chars = editor.getDocument().getCharsSequence();
|
||||
int stop = EngineEditorHelperKt.getLineEndOffset(new IjVimEditor(editor), caret.getLogicalPosition().line, true);
|
||||
|
||||
@ -1266,7 +1280,8 @@ public class SearchHelper {
|
||||
while (start > 0 && CharacterHelper.charType(chars.charAt(start - 1), false) == types[i]) {
|
||||
start--;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Search forward for start of word
|
||||
while (start < stop && CharacterHelper.charType(chars.charAt(start), false) != types[i]) {
|
||||
start++;
|
||||
@ -1288,7 +1303,8 @@ public class SearchHelper {
|
||||
(start >= chars.length() - 1 ||
|
||||
CharacterHelper.charType(chars.charAt(start + 1), false) != CharacterHelper.CharacterType.KEYWORD)) {
|
||||
end = start + 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
end = VimSearchHelperBase.Companion.findNextWordEnd(chars, start, stop, 1, false, false) + 1;
|
||||
}
|
||||
|
||||
@ -1296,8 +1312,7 @@ public class SearchHelper {
|
||||
}
|
||||
|
||||
@Contract("_, _, _, _, _, _, _ -> new")
|
||||
public static @NotNull
|
||||
TextRange findWordUnderCursor(@NotNull Editor editor,
|
||||
public static @NotNull TextRange findWordUnderCursor(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
int count,
|
||||
int dir,
|
||||
@ -1342,7 +1357,8 @@ public class SearchHelper {
|
||||
if ((!onWordStart && !(startSpace && isOuter)) || hasSelection || (count > 1 && dir == -1)) {
|
||||
if (dir == 1) {
|
||||
start = (int)VimSearchHelperBase.Companion.findNextWord(chars, pos, max, -1, isBig, !isOuter);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
start = (int)VimSearchHelperBase.Companion.findNextWord(chars, pos, max, -(count - (onWordStart && !hasSelection ? 1 : 0)), isBig, !isOuter);
|
||||
}
|
||||
|
||||
@ -1366,7 +1382,8 @@ public class SearchHelper {
|
||||
!hasSelection &&
|
||||
(!(startSpace && isOuter) || (startSpace && !isOuter)) ? 1 : 0), isBig,
|
||||
!isOuter);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
end = VimSearchHelperBase.Companion.findNextWordEnd(chars, pos, max, 1, isBig, !isOuter);
|
||||
}
|
||||
}
|
||||
@ -1475,7 +1492,8 @@ public class SearchHelper {
|
||||
|
||||
if (found == Math.abs(count)) {
|
||||
return pos;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1503,9 +1521,11 @@ public class SearchHelper {
|
||||
|
||||
if (res < 0 && (!requireAll || total == 1)) {
|
||||
res = dir > 0 ? max - 1 : 0;
|
||||
} else if (count > 0 && total > 1 && !requireAll) {
|
||||
}
|
||||
else if (count > 0 && total > 1 && !requireAll) {
|
||||
res = dir > 0 ? max - 1 : 0;
|
||||
} else if (count > 0 && total > 1 && requireAll) {
|
||||
}
|
||||
else if (count > 0 && total > 1 && requireAll) {
|
||||
res = -count;
|
||||
}
|
||||
|
||||
@ -1535,9 +1555,11 @@ public class SearchHelper {
|
||||
|
||||
if (res < 0 && (!requireAll || total == 1)) {
|
||||
res = dir > 0 ? max - 1 : 0;
|
||||
} else if (count > 0 && total > 1 && !requireAll) {
|
||||
}
|
||||
else if (count > 0 && total > 1 && !requireAll) {
|
||||
res = dir > 0 ? max - 1 : 0;
|
||||
} else if (count > 0 && total > 1 && requireAll) {
|
||||
}
|
||||
else if (count > 0 && total > 1 && requireAll) {
|
||||
res = -count;
|
||||
}
|
||||
|
||||
@ -1559,7 +1581,8 @@ public class SearchHelper {
|
||||
// start < max was added to avoid exception and it may be incorrect
|
||||
if (start < max && chars.charAt(start) == '\n' && !countCurrent) {
|
||||
end = findSentenceEnd(editor, chars, start, max, -1, false, multiple);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
end = findSentenceEnd(editor, chars, start, max, -1, true, multiple);
|
||||
}
|
||||
if (end == start && countCurrent && chars.charAt(end) == '\n') {
|
||||
@ -1580,13 +1603,16 @@ public class SearchHelper {
|
||||
if (dir > 0) {
|
||||
if (offset == start && countCurrent) {
|
||||
return offset;
|
||||
} else if (offset > start) {
|
||||
}
|
||||
else if (offset > start) {
|
||||
return offset;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (offset == start && countCurrent) {
|
||||
return offset;
|
||||
} else if (offset < start) {
|
||||
}
|
||||
else if (offset < start) {
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
@ -1594,7 +1620,8 @@ public class SearchHelper {
|
||||
|
||||
if (dir > 0) {
|
||||
end = findSentenceEnd(editor, chars, start, max, dir, true, multiple);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
end = findSentenceEnd(editor, chars, pos, max, dir, countCurrent, multiple);
|
||||
}
|
||||
|
||||
@ -1616,12 +1643,14 @@ public class SearchHelper {
|
||||
if (np < res || res < start) {
|
||||
res = np;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (np > res || (res >= start && !countCurrent)) {
|
||||
res = np;
|
||||
}
|
||||
}
|
||||
} else if (res == -1 && np >= 0) {
|
||||
}
|
||||
else if (res == -1 && np >= 0) {
|
||||
res = np;
|
||||
}
|
||||
// else we found neither, res already -1
|
||||
@ -1638,7 +1667,8 @@ public class SearchHelper {
|
||||
boolean multiple) {
|
||||
if (dir > 0 && start >= EditorHelperRt.getFileSize(editor) - 1) {
|
||||
return -1;
|
||||
} else if (dir < 0 && start <= 0) {
|
||||
}
|
||||
else if (dir < 0 && start <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1679,16 +1709,19 @@ public class SearchHelper {
|
||||
// Skip back to the sentence end so we can search backward from there
|
||||
// for the real previous sentence.
|
||||
offset = end;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Yeah - we found the real end-of-sentence. Save it off.
|
||||
res = offset - 1;
|
||||
found = true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Turned out not to be an end-of-sentence so move back to where we were.
|
||||
offset = end;
|
||||
}
|
||||
} else if (ch == '\n') {
|
||||
}
|
||||
else if (ch == '\n') {
|
||||
int end = offset; // Save where we found the newline.
|
||||
if (dir > 0) {
|
||||
offset++;
|
||||
@ -1707,18 +1740,21 @@ public class SearchHelper {
|
||||
if (offset == np && (end - 1 != start || countCurrent)) {
|
||||
res = end - 1;
|
||||
found = true;
|
||||
} else if (offset > end) {
|
||||
}
|
||||
else if (offset > end) {
|
||||
res = offset;
|
||||
np = res;
|
||||
found = true;
|
||||
} else if (offset == end) {
|
||||
}
|
||||
else if (offset == end) {
|
||||
if (offset > 0 && chars.charAt(offset - 1) == '\n' && countCurrent) {
|
||||
res = end;
|
||||
np = res;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (offset > 0) {
|
||||
offset--;
|
||||
while (offset > 0) {
|
||||
@ -1735,7 +1771,8 @@ public class SearchHelper {
|
||||
if (offset < end) {
|
||||
if (end == start && countCurrent) {
|
||||
res = end;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res = offset - 1;
|
||||
}
|
||||
|
||||
@ -1761,7 +1798,8 @@ public class SearchHelper {
|
||||
if (np < res || res < start) {
|
||||
res = np;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (np > res || (res >= start && !countCurrent)) {
|
||||
res = np;
|
||||
}
|
||||
@ -1805,10 +1843,12 @@ public class SearchHelper {
|
||||
which = 0;
|
||||
if (oneway) {
|
||||
findend = dir > 0;
|
||||
} else if (dir > 0 && start < max - 1 && !Character.isSpaceChar(chars.charAt(start + 1))) {
|
||||
}
|
||||
else if (dir > 0 && start < max - 1 && !Character.isSpaceChar(chars.charAt(start + 1))) {
|
||||
findend = true;
|
||||
}
|
||||
} else if (start == snext) // On sentence start
|
||||
}
|
||||
else if (start == snext) // On sentence start
|
||||
{
|
||||
if (dir < 0 && !oneway) {
|
||||
return start;
|
||||
@ -1818,7 +1858,8 @@ public class SearchHelper {
|
||||
if (dir < 0 && oneway) {
|
||||
findend = false;
|
||||
}
|
||||
} else if (start == enext) // On sentence end
|
||||
}
|
||||
else if (start == enext) // On sentence end
|
||||
{
|
||||
if (dir > 0 && !oneway) {
|
||||
return start;
|
||||
@ -1828,30 +1869,37 @@ public class SearchHelper {
|
||||
if (dir > 0 && oneway) {
|
||||
findend = true;
|
||||
}
|
||||
} else if (start >= sprev && start <= enext && enext < snext) // Middle of sentence
|
||||
}
|
||||
else if (start >= sprev && start <= enext && enext < snext) // Middle of sentence
|
||||
{
|
||||
which = dir > 0 ? 1 : 0;
|
||||
} else // Between sentences
|
||||
}
|
||||
else // Between sentences
|
||||
{
|
||||
which = dir > 0 ? 0 : 1;
|
||||
if (dir > 0) {
|
||||
if (oneway) {
|
||||
if (start < snext - 1) {
|
||||
findend = true;
|
||||
} else if (start == snext - 1) {
|
||||
}
|
||||
else if (start == snext - 1) {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
findend = true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (oneway) {
|
||||
if (start > eprev + 1) {
|
||||
findend = false;
|
||||
} else if (start == eprev + 1) {
|
||||
}
|
||||
else if (start == eprev + 1) {
|
||||
count++;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
findend = true;
|
||||
}
|
||||
}
|
||||
@ -1861,7 +1909,8 @@ public class SearchHelper {
|
||||
for (; count > 0 && res >= 0 && res <= max - 1; count--) {
|
||||
if ((toggle && which % 2 == 1) || (isOuter && findend)) {
|
||||
res = findSentenceEnd(editor, chars, res, max, dir, false, total > 1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
res = findSentenceStart(editor, chars, res, max, dir, false, total > 1);
|
||||
}
|
||||
if (res == 0 || res == max - 1) {
|
||||
@ -1871,7 +1920,8 @@ public class SearchHelper {
|
||||
if (toggle) {
|
||||
if (which % 2 == 1 && dir < 0) {
|
||||
res++;
|
||||
} else if (which % 2 == 0 && dir > 0) {
|
||||
}
|
||||
else if (which % 2 == 0 && dir > 0) {
|
||||
res--;
|
||||
}
|
||||
}
|
||||
@ -1881,7 +1931,8 @@ public class SearchHelper {
|
||||
|
||||
if (res < 0 || count > 0) {
|
||||
res = dir > 0 ? (max > 0 ? max - 1 : 0) : 0;
|
||||
} else if (isOuter && ((dir < 0 && findend) || (dir > 0 && !findend))) {
|
||||
}
|
||||
else if (isOuter && ((dir < 0 && findend) || (dir > 0 && !findend))) {
|
||||
if (res != 0 && res != max - 1) {
|
||||
res -= dir;
|
||||
}
|
||||
@ -1895,8 +1946,7 @@ public class SearchHelper {
|
||||
}
|
||||
|
||||
@Contract("_, _, _, _ -> new")
|
||||
public static @NotNull
|
||||
TextRange findSentenceRange(@NotNull Editor editor,
|
||||
public static @NotNull TextRange findSentenceRange(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
int count,
|
||||
boolean isOuter) {
|
||||
@ -1923,7 +1973,8 @@ public class SearchHelper {
|
||||
|
||||
return new TextRange(end, start + 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int end = findSentenceRangeEnd(editor, chars, offset, max, count, isOuter, false);
|
||||
|
||||
boolean space = isOuter;
|
||||
@ -1943,9 +1994,11 @@ public class SearchHelper {
|
||||
int maxline = new IjVimEditor(editor).lineCount();
|
||||
if (line >= 0 && line < maxline) {
|
||||
return new IjVimEditor(editor).getLineStartOffset(line);
|
||||
} else if (line == maxline) {
|
||||
}
|
||||
else if (line == maxline) {
|
||||
return count > 0 ? EditorHelperRt.getFileSize(editor) - 1 : 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1959,7 +2012,8 @@ public class SearchHelper {
|
||||
|
||||
if (line >= 0) {
|
||||
return new IjVimEditor(editor).getLineStartOffset(line);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return dir > 0 ? EditorHelperRt.getFileSize(editor) - 1 : 0;
|
||||
}
|
||||
}
|
||||
@ -1982,7 +2036,8 @@ public class SearchHelper {
|
||||
|
||||
if (total == 1 && line < 0) {
|
||||
line = dir > 0 ? maxline - 1 : 0;
|
||||
} else if (total > 1 && count == 0 && line < 0) {
|
||||
}
|
||||
else if (total > 1 && count == 0 && line < 0) {
|
||||
line = dir > 0 ? maxline - 1 : 0;
|
||||
}
|
||||
|
||||
@ -2025,8 +2080,7 @@ public class SearchHelper {
|
||||
return line;
|
||||
}
|
||||
|
||||
public static @Nullable
|
||||
TextRange findParagraphRange(@NotNull Editor editor,
|
||||
public static @Nullable TextRange findParagraphRange(@NotNull Editor editor,
|
||||
@NotNull Caret caret,
|
||||
int count,
|
||||
boolean isOuter) {
|
||||
@ -2040,7 +2094,8 @@ public class SearchHelper {
|
||||
if (isOuter) {
|
||||
if (EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), line, true)) {
|
||||
sline = line;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sline = findNextParagraphLine(editor, caret, -1, true);
|
||||
}
|
||||
|
||||
@ -2054,25 +2109,30 @@ public class SearchHelper {
|
||||
if (sline == line) {
|
||||
eline--;
|
||||
fixstart = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sline++;
|
||||
fixend = true;
|
||||
}
|
||||
} else if (!EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), eline, true) &&
|
||||
}
|
||||
else if (!EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), eline, true) &&
|
||||
!EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), sline, true) &&
|
||||
sline > 0) {
|
||||
sline--;
|
||||
fixstart = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), eline, true)) {
|
||||
fixend = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), sline, true)) {
|
||||
fixstart = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sline = line;
|
||||
if (!EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), sline, true)) {
|
||||
sline = findNextParagraphLine(editor, caret, -1, true);
|
||||
@ -2080,7 +2140,8 @@ public class SearchHelper {
|
||||
sline++;
|
||||
}
|
||||
eline = line;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
eline = line - 1;
|
||||
}
|
||||
|
||||
@ -2091,11 +2152,13 @@ public class SearchHelper {
|
||||
if (eline < 0) {
|
||||
if (i == count - 1) {
|
||||
eline = maxline - 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
eline++;
|
||||
}
|
||||
which++;
|
||||
@ -2109,7 +2172,8 @@ public class SearchHelper {
|
||||
while (sline > 0) {
|
||||
if (EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), sline - 1, true)) {
|
||||
sline--;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2121,7 +2185,8 @@ public class SearchHelper {
|
||||
while (eline < maxline - 1) {
|
||||
if (EngineEditorHelperKt.isLineEmpty(new IjVimEditor(editor), eline + 1, true)) {
|
||||
eline++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2146,8 +2211,7 @@ public class SearchHelper {
|
||||
return PsiHelper.findMethodEnd(editor, caret.getOffset(), count);
|
||||
}
|
||||
|
||||
private static @NotNull
|
||||
String getPairChars() {
|
||||
private static @NotNull String getPairChars() {
|
||||
if (pairsChars == null) {
|
||||
VimPlugin.getOptionGroup().addListener(
|
||||
OptionConstants.matchpairs,
|
||||
@ -2164,8 +2228,7 @@ public class SearchHelper {
|
||||
return pairsChars;
|
||||
}
|
||||
|
||||
private static @NotNull
|
||||
String parseMatchPairsOption() {
|
||||
private static @NotNull String parseMatchPairsOption() {
|
||||
List<String> pairs = globalOptions(injector).getStringListValues(OptionConstants.matchpairs);
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (String s : pairs) {
|
||||
@ -2195,10 +2258,8 @@ public class SearchHelper {
|
||||
private final int position;
|
||||
}
|
||||
|
||||
private static @Nullable
|
||||
String pairsChars = null;
|
||||
private static final @NotNull
|
||||
String blockChars = "{}()[]<>";
|
||||
private static @Nullable String pairsChars = null;
|
||||
private static final @NotNull String blockChars = "{}()[]<>";
|
||||
|
||||
private static final Logger logger = Logger.getInstance(SearchHelper.class.getName());
|
||||
}
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1845,8 +1845,7 @@ internal class RegExp {
|
||||
RE_COL -> if (!re_num_cmp(reginput!!.pointer() - regline!!.pointer() + 1, scan)) {
|
||||
return false
|
||||
}
|
||||
RE_VCOL -> {
|
||||
}
|
||||
RE_VCOL -> {}
|
||||
BOW -> if (c == '\u0000') /* Can't match at end of line */ {
|
||||
return false
|
||||
} else {
|
||||
@ -2064,10 +2063,8 @@ internal class RegExp {
|
||||
}
|
||||
reginput!!.inc()
|
||||
}
|
||||
NOTHING -> {
|
||||
}
|
||||
BACK -> {
|
||||
}
|
||||
NOTHING -> {}
|
||||
BACK -> {}
|
||||
MOPEN, MOPEN + 1, MOPEN + 2, MOPEN + 3, MOPEN + 4, MOPEN + 5, MOPEN + 6, MOPEN + 7, MOPEN + 8, MOPEN + 9 -> {
|
||||
val no: Int
|
||||
val save = save_se_T()
|
||||
|
@ -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 -> {
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
@ -234,7 +226,8 @@ public class ExOutputPanel extends JPanel {
|
||||
private void handleEnter() {
|
||||
if (myAtEnd) {
|
||||
close();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
scrollLine();
|
||||
}
|
||||
}
|
||||
@ -253,7 +246,8 @@ public class ExOutputPanel extends JPanel {
|
||||
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()));
|
||||
@ -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();
|
||||
|
@ -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()) {
|
||||
@ -240,8 +241,7 @@ public class ExEntryPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
@ -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);
|
||||
@ -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.
|
||||
@ -376,11 +379,13 @@ public class ExTextField extends JTextField {
|
||||
private void resetCaret() {
|
||||
if (getCaretPosition() == super.getText().length() || currentActionPromptCharacterOffset == super.getText().length() - 1) {
|
||||
setNormalModeCaret();
|
||||
} else {
|
||||
}
|
||||
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
|
||||
@ -511,15 +518,15 @@ public class ExTextField extends JTextField {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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>()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 ->
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -84,8 +84,7 @@ public abstract class VimDigraphGroupBase() : VimDigraphGroup {
|
||||
return true
|
||||
}
|
||||
|
||||
private val defaultDigraphs = charArrayOf(
|
||||
/*
|
||||
private val defaultDigraphs = charArrayOf( /*
|
||||
'N', 'U', // 0 ^@
|
||||
'S', 'H', // 1 ^A
|
||||
'S', 'X', // 2 ^B
|
||||
|
@ -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
|
||||
|
||||
|
@ -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),
|
||||
|
@ -201,7 +201,6 @@ public abstract class VimSearchHelperBase : VimSearchHelper {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
public fun findNextWordEnd(
|
||||
chars: CharSequence,
|
||||
pos: Int,
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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, "")
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user