Class: Ruvi::Completion::FilenameCompleter
- Inherits:
-
Object
- Object
- Ruvi::Completion::FilenameCompleter
- Defined in:
- lib/plugins/completion.rb
Instance Method Summary collapse
-
#initialize(app) ⇒ FilenameCompleter
constructor
A new instance of FilenameCompleter.
Constructor Details
#initialize(app) ⇒ FilenameCompleter
Returns a new instance of FilenameCompleter.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/plugins/completion.rb', line 4 def initialize app @app = app @app.add_command_binding("\C-x\C-f") { buffer = @app.current_buffer current_line = buffer.lines[buffer.y] filename = nil idx = -1 while true idx = current_line.index "/", idx + 1 return if idx.nil? filename = current_line[idx..buffer.x] break if File.exists? File.dirname(filename) end to_insert = Dir[filename+"*"].first.slice filename.length..-1 EditorApp::DiffLogger::ModifyLineChange.new(buffer, buffer.y) { buffer.lines[buffer.y][buffer.ax, 0] = to_insert EditorApp.invalidate_buffer_line buffer, buffer.y } buffer.x += to_insert.length } end |