Skip to content

Commit

Permalink
Support more flexible command line restrictions for Fleet
Browse files Browse the repository at this point in the history
  • Loading branch information
lippfi committed Aug 21, 2024
1 parent f4bca24 commit 9b347c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package com.maddyhome.idea.vim.api
import com.maddyhome.idea.vim.command.Command

interface VimCommandLineService {
fun isCommandLineSupported(editor: VimEditor): Boolean

fun getActiveCommandLine(): VimCommandLine?

fun readInputAndProcess(vimEditor: VimEditor, context: ExecutionContext, prompt: String, finishOn: Char?, processing: (String) -> Unit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import com.maddyhome.idea.vim.state.mode.ReturnableFromCmd
import com.maddyhome.idea.vim.state.mode.inVisualMode

abstract class VimCommandLineServiceBase : VimCommandLineService {
override fun isCommandLineSupported(editor: VimEditor): Boolean {
return !editor.isOneLineMode()
}

abstract fun createPanel(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine

private fun createCommandLinePrompt(editor: VimEditor, context: ExecutionContext, removeSelections: Boolean, label: String, initialText: String): VimCommandLine {
if (editor.isOneLineMode()) throw ExException("Command line is not allowed in one line editors")
if (!isCommandLineSupported(editor)) throw ExException("Command line is not allowed in one line editors")

val currentMode = editor.mode
check(currentMode is ReturnableFromCmd) {
Expand Down

0 comments on commit 9b347c9

Please sign in to comment.