ffes / nppsnippets

Code Snippets plugin for Notepad++
https://www.fesevur.com/nppsnippets
GNU General Public License v2.0
71 stars 12 forks source link

Does nppsnippets respect TABed cursor position #59

Open BW2001 opened 1 year ago

BW2001 commented 1 year ago

Hello

I have a lot of TABed code and find that the plugin doesn’t respect the initial cursor TABed (or multiple space indent) position for the inserted snippet code -see below. Is there anything I can do to fix this anomaly.

Before cursor

<empty line>
Nameobject(folderName);
BeginFolderN(kSYMBOLDEFS); {kSYMBOLDEFS = 16;}
<empty line>

After cursor

<empty line>
EndFolder;

Some example code

                SetSelect(objH);
                <-cursor
  end;

If I add snippet at cursor position above, I get the following

                SetSelect(objH);

Nameobject(folderName);
BeginFolderN(kSYMBOLDEFS); {kSYMBOLDEFS = 16;}
<-cursor                 
                  EndFolder;
  end;
ffes commented 1 year ago

Since v1.6.0 snippets should be inserted with the indention, but as mentioned in the release notes, I have only been able to test it for a few languages.

From your report I am not able to spot what language you are using. Could you please tell me, so I can take a closer look.

BW2001 commented 1 year ago

Hello

Thanks for responding.

I am new to Notepad++ and snippets. I have had another look at the problem and it seems that the snippets plugin ignores indents (ie TAB or spaces) within the body text – see attached screen grab I tried various combinations and found a workaround using “Before cursor” entry only followed by selection and TABbing to correct indent although not ideal.

Also, is there any way I can change the target language. Originally I edited the overrideMap to refer to a copy of Pascal function definition ie I have since created a UDL (user defined language). The problem is that snippets refers to previous definition. Is there any way to change the referenced language (otherwise I will have to rebuild from scratch). I had a look at the SQLlite database – table “LibraryLang”/Lang = 11 What is the language reference number for a UDL? If I haven’t missed it, can I change snippets language in the UI.

The language is a derivative of Pascal

Vectorscript web page https://developer.vectorworks.net/index.php/VectorScript

Good Example https://developer.vectorworks.net/index.php/VS:Progress_Dialog

Thanks

Bill Wood

From: Frank Fesevur @.> Sent: Friday, June 9, 2023 8:30 PM To: ffes/nppsnippets @.> Cc: BW2001 @.>; Author @.> Subject: Re: [ffes/nppsnippets] Does nppsnippets respect TABed cursor position (Issue #59)

Since v1.6.0 snippets should be inserted with the indention, but as mentioned in the release notes, I have only been able to test it for a few languages.

From your report I am not able to spot what language you are using. Could you please tell me, so I can take a closer look.

— Reply to this email directly, view it on GitHubhttps://github.com/ffes/nppsnippets/issues/59#issuecomment-1585041282, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOVBNSVH2HH3LGGAE6J2H7LXKN2S7ANCNFSM6AAAAAAY6K5OZE. You are receiving this because you authored the thread.Message ID: @.***>

ffes commented 1 year ago

There are various issues with UDL and plugins (including my Snippets plugin). AFAIK for a plugin it is impossible to properly detect a UDL. Therefore things like adding the right language to a libraries, and apparently indenting (haven't tested it myself yet) don't work. See #43 as well.

timint commented 1 year ago

+1

Looking back at the whitespace before insert position, and prepending it to each and every following linebreak should solve the problem.