Sign in to follow this  
Followers 0
Nutster

Bug in SciTE

40 posts in this topic

How can I prevent the auto-compeletion of words while I am entering a comment or inside a string literal? It is useful when I am typing in code, but a pain in the @$$ when I entering comments or strings.

Is there a way to tell SciTE not to auto-complete in strings and comments?


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites



Yeap you did... and i replied something like:

"Do as I... watch your fingers while your typing and just keep on typing".. :ph34r:

seriously, maybe you guys need to post something at the

scite-interest site about this and see what they say :

http://mailman.lyra.org/mailman/listinfo/scite-interest


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hmm, wonder if Lua has an answer...

Share this post


Link to post
Share on other sites

Hmm, wonder if Lua has an answer...

You mean something like "while in comment switch off autocomplete" in the OnChar event?

:ph34r:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Still... I would like to turn off that feature completely.

Share this post


Link to post
Share on other sites

You mean something like "while in comment switch off autocomplete" in the OnChar event?

:ph34r:

Something like that, yes. This is totally pseudo and could be wrong, still doing research on it:

function OnChar(c)
    ls = editor.LineState
    if ls == SCE_AU3_COMMENTBLOCK or ls == SCE_AU3_COMMENT then
        if scite.SendEditor(SCI_AUTOCACTIVE) then
            scite.SendEditor(SCI_AUTOCCANCEL)
        end
    end
end

That is totally untested and there could be multiple misunderstandings in my interpretation of the Lua docs and functions/properties.

Share this post


Link to post
Share on other sites

Still... I would like to turn off that feature completely.

What feature ? autocomplete ?

if thats what you want then just add this to the Users settings file:

autocomplete.au3.start.characters=


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

After much dumbass-ing around, I have something that works, although it's somewhat dangerous at the moment (I'll fix it soon). The danger comes in if you edit any other documents and the current style happens to match AutoIt's comment styles, you won't get auto-complete.

function OnChar(c)
    -- At this time, AutoIt's lexer is 60, this is unlikely to change.
    if editor.Lexer ~= 60 then return false end
    ls = editor.StyleAt[editor.CurrentPos]
    if ls == SCE_AU3_COMMENTBLOCK or ls == SCE_AU3_COMMENT then
        if editor:AutoCActive()  then 
            editor:AutoCCancel()     
        end
        return true    -- The key is here, this says don't process any more.
    end
end

For the curious, the dumbass-ing came with my lack of knowledge of Lua and thus, I couldn't figure out how to correctly use editor.StyleAt for the LONGEST time.

Edit 1: Oh, for those who don't know how to use this, place it in your lua startup script. By default, it's called "SciTEStartup.lua" and is in SciTE's installation directory. (Coming soon will be a fix to make sure this only works with AutoIt files)

Edit 2: Fixed code so it should only work when the AutoIt lexer is running.

Edited by Valik

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

After much dumbass-ing around, I have something that works, although it's somewhat dangerous at the moment (I'll fix it soon).  The danger comes in if you edit any other documents and the current style happens to match AutoIt's comment styles, you won't get auto-complete.

function OnChar(c)
    ls = editor.StyleAt[editor.CurrentPos]
    if ls == SCE_AU3_COMMENTBLOCK or ls == SCE_AU3_COMMENT then
        if editor:AutoCActive()  then 
            editor:AutoCCancel()     
        end
        return true    -- The key is here, this says don't process any more.
    end
    return false
end

For the curious, the dumbass-ing came with my lack of knowledge of Lua and thus, I couldn't figure out how to correctly use editor.StyleAt for the LONGEST time.

Edit 1:  Oh, for those who don't know how to use this, place it in your lua startup script.  By default, it's called "SciTEStartup.lua" and is in SciTE's installation directory. (Coming soon will be a fix to make sure this only works with AutoIt files)

Thought it was just me not be able to get that to work :ph34r:

Glad you figured it out... works neat....

EDIT: can also be added to the Autoit3.LUA script that comes with the standard install ... then it works only on the AutoIt3 files !!!

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Valik, when you add this to the AU3.Properties:

# Standard Autoit3 LUA Functions

extension.*.au3=$(SciteDefaultHome)\AutoIt3.lua

And add your function to AutoIt3.lua it will only work on AU3 files.

I will add it to the AutoIt3.lua supplied with the Scite4Autoit3 installset..


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

@Valik, when you add this to the AU3.Properties:

# Standard Autoit3 LUA Functions

extension.*.au3=$(SciteDefaultHome)\AutoIt3.lua

And add your function to AutoIt3.lua it will only work on AU3 files.

I will add it to the AutoIt3.lua supplied with the Scite4Autoit3 installset..

I've ammended my original post. I added a line to check the lexer and if it's AutoIt's, then it does it's thing. It was easier than I thought. I'm mostly making this post just to make sure you and anybody else who grabbed the first version is aware that I hard-coded a check in.

Obviously, the auto-complete thing sort of annoyed me, too, or I wouldn't of spent this much time on it. :ph34r: At least I did learn a little more about Lua, though...

Share this post


Link to post
Share on other sites

For those of you who have the used the standard Scite4Autoit3 installset:

Here a new http://www.autoitscript.com/fileman/users/jdeb/autoit3.lua .. download it and replace the current version in the Scite program directory and Autocomplete will be disabled in Comment lines/Blocks...

thanks Valik...


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Think we should also stop autocomplete inside a String .. Agree ??

function OnChar(a)
   ls = editor.StyleAt[editor.CurrentPos]
   if ls == SCE_AU3_COMMENTBLOCK or ls == SCE_AU3_COMMENT or ls == SCE_AU3_STRING then
       if editor:AutoCActive()  then 
           editor:AutoCCancel()     
       end
       return true    -- The key is here, this says don't process any more.
   end
   return false
end

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I knew there was some other place I wanted to suppress autocomplete, I just couldn't think of it. In strings was probably it.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

That is exactly what I wanted. :ph34r:

Thank you.

Edit: Just tested it but it did not seem to work. Copy it into the SciTE folder (C:\Program Files\SciTE) and it replaces the one that is already there and then check. I still get the AutoComplete box. Do I have to reboot my Windows 98 machine to get SciTE to read the new LUA file?

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Just stop and start Scite should do....

EDIT: When you are running the Scite4autoit3 it should be installed in C:\Program Files\AutoIt3\SciTE

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

so, is the http://www.autoitscript.com/fileman/users/jdeb/autoit3.lua supposed to block autocomplete in strings? that doesn't seem to work for me. Even making sure it has this code didn't do it.

function OnChar(a)
  ls = editor.StyleAt[editor.CurrentPos]
  if ls == SCE_AU3_COMMENTBLOCK or ls == SCE_AU3_COMMENT or ls == SCE_AU3_STRING then
      if editor:AutoCActive()  then 
          editor:AutoCCancel()     
      end
      return true    -- The key is here, this says don't process any more.
  end
  return false
end

I just typed $banana = "win and got the autocomplete.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

First things first, modify the Lua function to print to the output pane as follows:

function OnChar(a)
_ALERT("Inside OnChar()")
    ls = editor.StyleAt[editor.CurrentPos]
<rest of the function>

Save it, restart SciTE, then try again. If you are seeing "Inside OnChar()" in the output pane each time you type a character, then something else is screwed up. But if you are not seeing that, then something is misconfigured.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

yeah, there is a

Inside OnChar()

message for each character typed (in quotes or out of them).

When it's $banana = "win" it doesn't autocomplete, it's when there's no closing quote that it still autocompletes...

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0