Skip to content

Commit

Permalink
console.lua: trim commands before saving them in history
Browse files Browse the repository at this point in the history
This avoids storing similar commands in history that only differ by
leading or trailing whitespace, like "sub-reload" and "sub-reload ". It
is easy to get these otherwise because Tab completion leaves a trailing
space after commands.
  • Loading branch information
guidocella committed Oct 28, 2024
1 parent 8d91fd9 commit db59907
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions player/lua/console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ local function handle_enter()
return
end

line = line:match('^%s*(.-)%s*$')

if line == '' and input_caller == nil then
return
end
Expand Down

0 comments on commit db59907

Please sign in to comment.