Programming TextMate in Ruby. Problem with TextMate.go_to

I am modding the TextMate package, although I'm a complete newbie to Ruby. The problem I'm trying to solve is to move the carriage to a specific position after the team has reached its conclusion.

Basically, what happens: I click on a key combo that launches a command to filter through a document and inserts text into the appropriate places, and then exits with replacing the document with new filtered text.

What I want to do next is that the carriage will return to where it was originally. I was very happy when I found the TextMate.go_to function, but I can only partially work it out. Function:

positionY = ENV ['TM_LINE_NUMBER']
positionX = ENV ['TM_LINE_INDEX']
...
TextMate.go_to: line => positionY,: column => positionX; #column no worky

I can get the caret in the correct row, but the column parameter is not working. I tried to shift them and even execute the function with only the column parameter, but no luck. I also tried with a hard-coded integer, but the positionX parameter prints the correct line index, so I doubt that there is anything there.

This is the only documentation I found on this method, but I looked at textmate.rb and it seems to my unprepared eyes that I am using it correctly.

, , , . , , " ", , , , " ". -?

+3
1

:

def go_to(options = {})
  default_line = options.has_key?(:file) ? 1 : ENV['TM_LINE_NUMBER']
  options = {:file => ENV['TM_FILEPATH'], :line => default_line, :column => 1}.merge(options)
  if options[:file]
    `open "txmt://open?url=file://#{e_url options[:file]}&line=#{options[:line]}&column=#{options[:column]}"`
  else
    `open "txmt://open?line=#{options[:line]}&column=#{options[:column]}"`
  end
end

, URL- txmt:// .

, , , - URL- Terminal/your browser, , TextMate . , , Textmate.go_to.

+4

Source: https://habr.com/ru/post/1704432/


All Articles