-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement motions to go to next/previous misspelled word
- Loading branch information
Showing
5 changed files
with
137 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/motion/text/MotionMisspelledWord.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2003-2023 The IdeaVim authors | ||
* | ||
* Use of this source code is governed by an MIT-style | ||
* license that can be found in the LICENSE.txt file or at | ||
* https://opensource.org/licenses/MIT. | ||
*/ | ||
package com.maddyhome.idea.vim.action.motion.text | ||
|
||
import com.intellij.vim.annotations.CommandOrMotion | ||
import com.intellij.vim.annotations.Mode | ||
import com.maddyhome.idea.vim.api.ExecutionContext | ||
import com.maddyhome.idea.vim.api.ImmutableVimCaret | ||
import com.maddyhome.idea.vim.api.VimEditor | ||
import com.maddyhome.idea.vim.api.injector | ||
import com.maddyhome.idea.vim.command.Argument | ||
import com.maddyhome.idea.vim.command.CommandFlags | ||
import com.maddyhome.idea.vim.command.MotionType | ||
import com.maddyhome.idea.vim.command.OperatorArguments | ||
import com.maddyhome.idea.vim.handler.Motion | ||
import com.maddyhome.idea.vim.handler.MotionActionHandler | ||
import com.maddyhome.idea.vim.handler.toMotionOrError | ||
import com.maddyhome.idea.vim.helper.enumSetOf | ||
import java.util.* | ||
|
||
@CommandOrMotion(keys = ["]s"], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING]) | ||
public class MotionMisspelledWordNextAction : MotionActionHandler.ForEachCaret() { | ||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_JUMP) | ||
|
||
override fun getOffset( | ||
editor: VimEditor, | ||
caret: ImmutableVimCaret, | ||
context: ExecutionContext, | ||
argument: Argument?, | ||
operatorArguments: OperatorArguments, | ||
): Motion { | ||
return injector.searchHelper.findMisspelledWord(editor, caret, operatorArguments.count1).toMotionOrError() | ||
} | ||
|
||
override val motionType: MotionType = MotionType.EXCLUSIVE | ||
} | ||
|
||
@CommandOrMotion(keys = ["[s"], modes = [Mode.NORMAL, Mode.VISUAL, Mode.OP_PENDING]) | ||
public class MotionMisspelledWordPreviousAction : MotionActionHandler.ForEachCaret() { | ||
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_SAVE_JUMP) | ||
|
||
override fun getOffset( | ||
editor: VimEditor, | ||
caret: ImmutableVimCaret, | ||
context: ExecutionContext, | ||
argument: Argument?, | ||
operatorArguments: OperatorArguments, | ||
): Motion { | ||
return injector.searchHelper.findMisspelledWord(editor, caret, -operatorArguments.count1).toMotionOrError() | ||
} | ||
|
||
override val motionType: MotionType = MotionType.EXCLUSIVE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters