chrisgrieser / nvim-scissors

Automagical editing and creation of snippets.
MIT License
352 stars 3 forks source link

[Bug]: Cannot add multiline snippets #4

Closed Sombrer0Dev closed 8 months ago

Sombrer0Dev commented 8 months ago

Bug Description

If i try to add a new line before code snippet in preselected snippet or add a new line in an empty snippet it will start to register as a prefix

Relevant Screenshot

New snippet

(no new line)
image

(new line) image

Preselected snippet

(no new line) image

(new line before selected text) image

To Reproduce

New snippet

  1. require("scissors").addNewSnippet()
  2. write a prefix
  3. write something on a new line
  4. carriage return

    Preselected snippet

  5. require("scissors").addNewSnippet() in a visual mode
  6. write a prefix
  7. new line before selected text

neovim version

NVIM v0.10.0-dev-1988+g1ef60ea651
Build type: RelWithDebInfo
LuaJIT 2.1.1702233742

Make sure you have done the following

chrisgrieser commented 8 months ago

I am not entirely sure whether this is the issue you have, but due to the way this plugin treats positions the divider line (between prefix and body), pressing o on a prefix line creates another prefix line.

To add a new line something to the body, you'd have to press j, and then i.

chrisgrieser commented 8 months ago

Okay, I tweaked the behavior a bit, o on the prefix line now simply adds a line to be body. O on a prefix line still creates a new prefix line. Think that should be more intuitive.

zolrath commented 8 months ago

Edit: Hey you fixed this as I was writing the comment, nice.

I think the issue is if you:

the first line of the snippet moves up to the prefix.

Before hitting enter: image after pressing enter: image

chrisgrieser commented 8 months ago

@zolrath that behavior should be fixed with the latest commit I made a few seconds before your comment :P