akvelon / flutter-code-editor

Flutter Code Editor is a multi-platform code editor supporting syntax highlighting, code blocks folding, autocompletion, read-only code blocks, hiding specific code blocks, themes, and more.
https://akvelon.com
Apache License 2.0
212 stars 52 forks source link

Outdent on Backspace #218

Open sma opened 1 year ago

sma commented 1 year ago

I would like to implement a "dedent on backspace" but it seems a CodeModifier that wants to register itself on '\b' doesn't work. I checked that the backspace key is delegated to the CodeController's onKey method and you could process it there if nothing else works, but I think, a CodeModifier which is called on '\n' for indentation is the right place to implement this.

I'm using version 0.2.15.

alexeyinkin commented 1 year ago

Registering on '\b' does not work because the character to test against is produced from the diff of the two values. Since the value is not +1 char long, modifiers will not be triggered at all.

CodeModifiers are legacy from the old editor. We are going to drop them in favor of something better when we gather enough use cases like this one.