Whoops; a typo meant we were wrapping `#toggle_focus` in a guard, and then wrapping the wrapped version in another guard, which meant that it would end up calling itself repeatedly. Ouch. The added regression spec isn't super awesome; it passes with the fix, but hangs without the fix, so it is more documentation of what went wrong than a real regression test per-se. Fixes: #157
This was originally reported here: https://wincent.com/issues/2088 But for some reason it didn't repro for me then, but it definitely does now, with both `vim -R` and `view`. As soon as we try to make an assignment to `@@buffer[...]` Vim issues the warning. Make sure this doesn't happen by explicitly setting `noreadonly` in the "GoToFile" buffer.
It's true that this entire file is protected by a guard, but in case somebody really, really wants to re-evaluate it they could use `:unlet` to circumvent the guard and then re-source the file. So, let's just follow standard best practice of clearing the entire augroup before adding to it.
Vint is a vimscript linter. This commit makes some tweaks based on its suggestions. I don't think it found any substantive issues, but it makes sense for Command-T to be "clean" according to the linter. Issues addressed in this commit: - prefer single quotes over doubles (nothing potentially harmful was changed here) - use `function!` in "autoload/" (found a couple that I'd missed) - use `abort` keyword with "autoload/" functions (no real behavior change here, as all the functions a pretty much just one-liners that call Ruby, so there is on distinction between aborting and continuing) - explicitly choose case-sensitive string comparison (meaningless for empty strings, but let's do it anyway to keep the linter happy) : https://github.com/Kuniwak/vint
Rejigged things a bit in the scanner in order to make faking an error condition more straightforward, then we just verify that it falls back to the superclass.
Although, the `exitstatus.zero?` check is unlikely to fire; it seems that Watchman always returns with an exit code of 0 even for blatantly wrong invocations, and instead reports errors by the 'error' key in the results object.
As noted in the previous commit, the logic here wasn't really doing much because we were only lazily loading the extension, so the likely codepath was: 1. Try to load controller, fail 2. Modify load path 3. Try to load controller, succeed The comment in there about falling back to the stub if there was a problem with C extension wasn't really accurate. For example, if you forgot to compile the extension, you'd still go through the sequence above because we weren't even attempting to require it. Similarly, if you compiled with the wrong Ruby version, we wouldn't find out about it until later (and likely, with a segfault). So, this commit reworks the logic here to do two new things: - explicitly check run-time Ruby version against compile-time version; if we don't have metadata about the compile-time Ruby version we skip the check - eagerly load the extension so that we can report problems via the `Stub` as we originally intended; this will catch the case where the user forgets to compile Note that there is still one case that we can't handle, and that is the one where the extension was previously compiled with the wrong version of Ruby, but with an older version of Command-T so no metadata.rb file existed or was updated. In that scenario, we skip the version check and try to load the extension; because it exists but is the wrong version, we'll probably segfault. From experience, segfaults are pretty much assured if the mismatch is large (eg. 1.8.7 vs 2.0.0). If it's just a difference in patchlevel then you _might_ get a segfault at some later time (like during a search). In any case, I think this commit leaves us in a better place. I tested it with the following combinations: - mismatched `metadata.rb`: prints diagnostic info - unknown/default `metadata.rb`: loads and runs - missing extension: prints diagnostic info - unknown/default `metadata.rb` + big version mismatch (1.8.7 vs 2.0.0): segfaults
When you run `extconf.rb` we get the compile-time `RUBY_VERSION` and `RUBY_PATCHLEVEL` so that we can show it later on in a diagnostic message if you try to run in a version of Vim with a mismatched Ruby. Note that I say "prepare" to use it because in looking over this, I've realized that the existing `Stub` module is effectively useless. We're no longer eagerly loading the extension, which means that a failure to compile will never be the cause of us using `CommandT::Stub`. In fact, in order to get to the stub line, some other basic `require` has to have failed, which in turn means things are busted and the `require` for `Stub` likely won't work either. I'll address that in a separate commit.
This isn't just about "unavailability". Let the Watchman error messages show through in the exception text; it may be helpful, such as: > CommandT::Scanner::FileScanner::WatchmanFileScanner::WatchmanError: > unable to resolve root [PATH]: none of the files listed in global > config root_restrict_files are present
Put the `MatchWindow` autocmds in a group, and make the group names consistent across the project. Note that we don't need to worry about the `MatchWindow` autocmds leaking in normal use, because the window hangs around in the background and gets re-used.
One substantive fix in here: - add missing (unbalanced) paren in `commandt#CommandTPath` method And some other consistency/polish tweaks: - add some comments indicating what the added methods are for - use `&&` instead of `and` - remove redundant explicit `if`/`return true`/`else`/`return false` construct - allow `#path` and `#active_finder` methods to return `nil`; one of these requires a change to the caller to preserve desired behavior, but the other one can be left as-is (interpolating `nil` in a string is a no-op) - use parens around method parameter lists
Originally submitted at: #149 * gh/mathstuf/git-submodule-scan: doc: Update for the new g:CommandTGitScanSubmodules option Make @scan_submodules code work Expect g:CommandTGitScanSubmodules to be a boolean git: add option for scanning submodules
- whitespace fix - minor rewording, adding a link back to the `g:CommandTFileScanner` option - updated HISTORY and AUTHORS sections
Originally submitted in relation to: #151 For some reason, had a merge conflict, so in applying it, I took the opportunity to alphabetize the alternatives within the regex. Signed-off-by: Greg Hurrell <email@example.com>
* blueyed/highlight-fix: doc: Add info to HISTORY section for Daniel's patch DRY up repeated `#gsub` calls in `#get_cursor_highlight` Only use `highlight!` when needed Teach get_cursor_highlight to return an array Clean-up comments in MatchWindow#get_cursor_highlight Fix handling output of ":hi Cursor" with link + definition Originally submitted at: #150 With some follow-up from me.
As mentioned in ab15fa2, we previously used `:highlight` for everything, but the need to use `:highlight!` for some specific cases led us to use `:highlight!` for everything. This commit makes things a little more nuanced by marking the specific cases that need the bang, and using it only in those cases.