Commit Graph
1865 Commits
Author SHA1 Message Date
Matt EllisandAlex Plãte f83e982730 Fix associativity of ternary and falsy operators
Fixes VIM-3835
2025-11-07 15:56:39 +02:00
Matt EllisandAlex Plãte 115937f642 Consolidate unary expressions 2025-11-07 15:56:39 +02:00
Matt EllisandAlex Plãte 63cbb5b736 Fix use of is operator as variable name 2025-11-07 15:56:39 +02:00
Matt EllisandAlex Plãte fc6f2905be Fix is and isnot operators
The parser was treating `is` and `isnot` as identifiers instead of operators
2025-11-07 15:56:39 +02:00
dec2a89643 Remove dead code from VimStateMachineImpl
The companion function `modeToMappingMode` was not used anywhere in the codebase.
The extension function `toMappingMode()` serves the same purpose and is used throughout.
Also removed unused import and extra blank line for cleaner code formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 15:14:35 +02:00
3f2b716e72 Remove unused VimEditorGroupBase class
VimEditorGroupBase has been unused since its creation in April 2022. Unlike other
*Base classes in the api package (VimApplicationBase, VimMessagesBase, etc.),
VimEditorGroupBase is never extended. The actual EditorGroup implementation
directly implements the VimEditorGroup interface instead of extending this base class.

This removal cleans up dead code and reduces maintenance overhead.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-07 15:12:26 +02:00
Alex Plate 2de7394aa6 Add hasmapto functions for all modes
Implement mode-specific hasmapto functions following the MappingScope style:
- hasmapto() - checks nvo modes
- nhasmapto() - checks normal mode
- vhasmapto() - checks visual mode
- xhasmapto() - checks visual exclusive mode
- shasmapto() - checks select mode
- ohasmapto() - checks operator pending mode
- ihasmapto() - checks insert mode
- chasmapto() - checks command line mode

These functions check if any mapping exists that maps TO the given string,
which is essential for plugins to detect if users have already mapped to
their <Plug> mappings. This enables the common pattern: "only create default
key mapping if user hasn't already mapped to the <Plug> mapping".

Implementation delegates to VimKeyGroup.hasmapto().
2025-10-27 11:00:05 +02:00
Alex Plate 4c8c1cfcf2 Fix map/noremap/unmap to only affect nvo modes
The map/noremap/unmap functions should only affect Normal, Visual, Select,
and Operator-pending modes (nvo), not all modes including Insert and
Command-line. This matches Vim's behavior where :map affects nvo modes only.

Changed from MappingMode.ALL to MappingMode.NVO.
2025-10-27 11:00:04 +02:00
Alex Plate 2c383b4ad8 Reorganize MappingScope functions by mode type
Group mapping functions by mode instead of by operation type for better
organization and readability. Each mode group now contains:
- Recursive mapping (map variants)
- Non-recursive mapping (noremap variants)
- Unmap function

Order: map, nmap, vmap, xmap, smap, omap, imap, cmap

This makes the API more discoverable and easier to navigate.
2025-10-27 11:00:04 +02:00
Alex Plate e71e9714c2 Remove incorrect 3-argument mapping functions from API
The 3-argument mapping functions (e.g., nmap(keys, actionName, action)) had
incorrect implementation that used recursive mappings for both sub-mappings.
Also, this approach makes it impossible to implement other mapping features
such as skipping mapping registration if the mapping is already defined in
.ideavimrc.

A different solution for convenient mapping patterns will be implemented later.

Changes:
- Remove 16 three-argument function declarations from MappingScope interface
- Remove 16 three-argument function implementations from MappingScopeImpl
- Update ReplaceWithRegister plugins to use correct 2-step pattern:
  1. nnoremap("<Plug>...") for non-recursive <Plug> → action
  2. nmap("key", "<Plug>...") for recursive key → <Plug>

Total: 374 lines deleted, 18 lines added
2025-10-27 11:00:03 +02:00
Alex Plate 67a44b4d25 Fix boundary check and null safety in mapleader parsing
Adds length validation before accessing string indices and replaces unsafe
!! operator with proper null handling to prevent crashes on invalid mapleader values.
2025-10-24 14:31:23 +03:00
Matt EllisandAlex Plãte 54cc89f641 Fix missing read action exceptions 2025-10-24 14:29:58 +03:00
azjfandAlex Plãte 7f0ab93ea7 Return \<${specialKeyBuilder} for VimStringParserBase#parseVimScriptString(string: String) 2025-10-24 13:44:57 +03:00
azjfandAlex Plãte a0f923512a Add support for non-control-character mapleader such as \<C-Space> 2025-10-24 13:44:57 +03:00
12596540e9 Maintenance: Line matchers - Add defensive bounds checking
Added bounds checking to EndOfLineMatcher and StartOfLineMatcher to
prevent potential IndexOutOfBoundsException when index is outside the
valid text range. This follows the defensive programming pattern used
in other matchers like CharacterMatcher, DotMatcher, StartOfWordMatcher,
and EndOfWordMatcher.

Changes:
- EndOfLineMatcher: Added check for index > length before array access
- StartOfLineMatcher: Added check for index < 0 or index > length

While the NFA engine should prevent invalid indices, these defensive
checks improve code safety and consistency across all matcher
implementations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 08:44:51 +03:00
a9fc2c58a6 Maintenance: IndexedExpression - Fix off-by-one error and variable shadowing
Fixed three issues in IndexedExpression.kt:
1. Off-by-one error: Changed condition from `idx > text.length` to `idx >= text.length` to properly handle boundary cases when indexing strings
2. Redundant evaluation: Reused `indexValue` instead of re-evaluating `index.evaluate()` in the string indexing path
3. Variable shadowing: Renamed local variable from `index` to `indexNum` in `assignToListItem` to avoid shadowing the property

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 21:15:47 +03:00
1aa586484f Maintenance: Change actions - Remove wildcard imports
Replace wildcard import `java.util.*` with explicit import `java.util.EnumSet`
in 9 action classes in the change/change package. This improves code clarity
and follows the project's convention of avoiding wildcard imports.

Files updated:
- AutoIndentLinesVisualAction
- ChangeCharactersAction
- ChangeEndOfLineAction
- ChangeLineAction
- ChangeMotionAction
- ChangeVisualLinesAction
- ChangeVisualLinesEndAction
- FilterMotionAction
- ReformatCodeVisualAction

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 12:41:03 +03:00
Alex Plate d955b1b85c Fix an exception that we try to record wrong characters 2025-10-17 12:21:57 +03:00
82ed26a701 Maintenance: PrintLineNumberCommand - Fix out-of-bounds range handling
Add bounds checking to clamp line numbers to the last line of the document,
preventing potential exceptions when accessing line text with out-of-bounds
ranges like `:$+100=`. This matches the behavior of other commands like
GoToLineCommand.

Also add tests to verify the edge case behavior with and without flags.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 18:00:49 +03:00
Alex Plate cf5dce3ce7 Remove "getSelectionModel" from VimRegex.kt 2025-10-13 17:37:23 +03:00
bb62dcdc15 Maintenance: DeletePreviousWordAction - Update copyright and add test
Update copyright year to 2025 and add test coverage for edge case when
caret is at the beginning of the command line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-09 15:15:59 +03:00
Alex Plate fdcb954e31 Remove the VimSelectionModel as it's not used anywhere 2025-10-09 13:14:49 +02:00
Alex Plate 448c19af47 Fix SortCommand to use caret selection instead of editor selection model
The SortCommand was incorrectly using editor.getSelectionModel() which
returns the editor's global selection model. This is problematic in
multi-caret scenarios where each caret has its own independent selection.

Changed to use caret.hasSelection(), caret.selectionStart, and
caret.selectionEnd directly, which correctly handles per-caret selections.

This also removes the only meaningful usage of VimEditor.getSelectionModel()
in vim-engine, making that interface a candidate for removal in future
cleanup.
2025-10-09 13:09:38 +02:00
Alex Plate bdc29c3eb4 Add support for count(), index(), min(), max(), and range() vimscript functions
Implements five new vimscript list functions:
- count(): counts occurrences of a value in a list/dict
- index(): finds first index of a value in a list
- min()/max(): finds minimum/maximum value in a list/dict
- range(): generates a list of numbers with optional stride

Includes error handling for edge cases like zero stride and invalid ranges.
2025-10-03 20:59:29 +03:00
Alex Plate d46eb39635 Add support for repeat(), char2nr(), nr2char(), trim(), and reverse() vimscript functions
Implement five commonly used vimscript functions:

- repeat(expr, count): Repeats strings or lists multiple times
- char2nr(char): Converts character to Unicode code point
- nr2char(number): Converts code point to character
- trim(text, [mask], [dir]): Trims whitespace or custom characters
- reverse(object): Reverses lists in-place or returns reversed string

All functions include comprehensive test coverage and follow vim's
official behavior including edge cases.
2025-10-03 19:08:57 +03:00
Alex Plate a6c71d90bb Fix(VIM-4050): Implement getline vim function 2025-10-03 18:41:34 +03:00
Alex Plate 63c65c8b93 Migrate ExEntryPanel from Java to Kotlin and update related references 2025-10-03 13:30:19 +03:00
Matt EllisandAlex Plãte 6defddd24c Extract variable expression assignment 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte a916b4de9c Rename Variable to VariableExpression 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 8a0bdfd18f Improve sublist expression compatibility 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte db8736dcf4 Extract sublist expression assignment 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 4c3cefc1e6 Add typename for reporting purposes 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte b11fc4895b Support assigning to negative index 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte b7ce946af3 Extract sublist expression assignment
Also allows whitespace inside indexed expression
2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 5a45f6d945 Improve evaluating indexed expressions
Support negative indexes, float indexes, and indexing numbers
2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 6622f15ea3 Allow dictionary to be indexed by Float 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte fd1fe51633 Extract indexed expression assignment 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 91459edf6c Rename OneElementSublistExpression 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 01d92acd40 Improve validation for concatenation 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 6d18288883 Fix validation for modulo operator 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 7ffca59450 Support double-dot concatenation assignment 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 61df4f342d Support Float in concatenation handler
Surprisingly Float is converted to String, and then concatenated. But this is only supported for the binary concatenation operator, not the compound assignment concatenation operator. This lead to improved validation and behaviour closer to Vim.
2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 56d5af6bc9 Allow assigning Float to Register 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 1dbe3e4aa1 Update RegisterExpression to assign value 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 7256731572 Rename Register to RegisterExpression 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte dc5b45a52d Update OptionExpression to match Vim behaviour 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 063317b0c9 Introduce LValueExpression, update OptionExpression 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 37b6768148 Rename LetCommand.variable to lvalue 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 7fe01cd885 Add string() Vim function 2025-10-02 17:26:38 +03:00
Matt EllisandAlex Plãte 68f0e162e2 Update out of date error message 2025-10-02 17:26:38 +03:00