1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-26 08:56:54 +00:00

Adds support for colon operator in complete() function.

Includes changes to lua and edit programs to correctly support that too.
This commit is contained in:
Wojbie 2017-06-19 00:43:28 +02:00
parent 7e08662b95
commit 1489da1f5f
3 changed files with 15 additions and 4 deletions

View File

@ -353,8 +353,19 @@ function complete( sSearchText, tSearchTable )
return tEmpty
end
end
local sPart = string.sub( sSearchText, nStart, nDot )
local nColon = string.find( sSearchText, ":", nStart, true )
if nColon then
local sPart = string.sub( sSearchText, nStart, nColon - 1 )
local value = tTable[ sPart ]
if type( value ) == "table" then
tTable = value
nStart = nColon + 1
else
return tEmpty
end
end
local sPart = string.sub( sSearchText, nStart )
local nPartLength = string.len( sPart )
local tResults = {}

View File

@ -204,7 +204,7 @@ local nCompletion
local tCompleteEnv = _ENV
local function complete( sLine )
if settings.get( "edit.autocomplete" ) then
local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.]+$" )
local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.:]+$" )
if nStartPos then
sLine = string.sub( sLine, nStartPos )
end

View File

@ -34,7 +34,7 @@ while bRunning do
local s = read( nil, tCommandHistory, function( sLine )
if settings.get( "lua.autocomplete" ) then
local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.]+$" )
local nStartPos = string.find( sLine, "[a-zA-Z0-9_%.:]+$" )
if nStartPos then
sLine = string.sub( sLine, nStartPos )
end