Skip to content

Commit

Permalink
Add RWLock label to selectionStart & selectionEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPl292 committed Nov 15, 2024
1 parent 0e3cda8 commit b026144
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.maddyhome.idea.vim.group.visual.VisualChange
import com.maddyhome.idea.vim.group.visual.vimMoveBlockSelectionToOffset
import com.maddyhome.idea.vim.group.visual.vimMoveSelectionToCaret
import com.maddyhome.idea.vim.handler.Motion
import com.maddyhome.idea.vim.helper.RWLockLabel
import com.maddyhome.idea.vim.helper.StrictMode
import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.register.Register
Expand All @@ -40,7 +41,9 @@ interface ImmutableVimCaret {
val isValid: Boolean
val isPrimary: Boolean

@RWLockLabel.Readonly
val selectionStart: Int
@RWLockLabel.Readonly
val selectionEnd: Int
val vimSelectionStart: Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@

package com.maddyhome.idea.vim.group.visual

import com.maddyhome.idea.vim.api.*
import com.maddyhome.idea.vim.helper.*
import com.maddyhome.idea.vim.api.ImmutableVimCaret
import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.VimMotionGroupBase
import com.maddyhome.idea.vim.api.VimVisualPosition
import com.maddyhome.idea.vim.api.getLineEndOffset
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.isLineEmpty
import com.maddyhome.idea.vim.helper.RWLockLabel
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.state.mode.inBlockSelection
Expand Down Expand Up @@ -135,6 +142,7 @@ fun VimCaret.vimUpdateEditorSelection() {
/**
* This works almost like [Caret.getLeadSelectionOffset] in IJ, but vim-specific
*/
@RWLockLabel.Readonly
val ImmutableVimCaret.vimLeadSelectionOffset: Int
get() {
val caretOffset = offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ annotation class RWLockLabel {
* [Readonly] annotation means that annotated function should be called from read action
* This annotation is only a marker and doesn't enable r/w lock automatically
*/
@Target(AnnotationTarget.FUNCTION)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
annotation class Readonly

/**
Expand Down

0 comments on commit b026144

Please sign in to comment.