Beispiel #1
0
 private void doIncSearch() {
   String keyword = searchParser.getKeyWord();
   Search s =
       SearchCommandParser.createSearch(
           editorAdaptor, keyword, !forward, false, SearchOffset.NONE);
   SearchResult res = VimUtils.wrapAroundSearch(editorAdaptor, s, startPos);
   if (res.isFound()) {
     SearchAndReplaceService sars = editorAdaptor.getSearchAndReplaceService();
     sars.incSearchhighlight(res.getStart(), res.getModelLength());
     MotionCommand.gotoAndChangeViewPort(editorAdaptor, res.getStart(), StickyColumnPolicy.NEVER);
   } else {
     resetIncSearch();
   }
 }
Beispiel #2
0
    public <T> void optionChanged(Option<T> option, T oldValue, T newValue) {
      if (option.equals(Options.SMART_CASE)
          || option.equals(Options.IGNORE_CASE)
          || option.equals(Options.SEARCH_HIGHLIGHT)
          || option.equals(Options.SEARCH_REGEX)) {
        Search lastSearch = vim.getRegisterManager().getSearch();
        // Update the search settings for the last/active search.
        if (lastSearch != null) {
          lastSearch =
              SearchCommandParser.createSearch(
                  vim,
                  lastSearch.getKeyword(),
                  lastSearch.isBackward(),
                  lastSearch.isWholeWord(),
                  lastSearch.getSearchOffset());

          if (Options.SEARCH_HIGHLIGHT.equals(option) && Boolean.FALSE.equals(newValue)) {
            vim.getSearchAndReplaceService().removeHighlighting();

            // Update highlights when enabled, as search might now match more things
          } else if (vim.getConfiguration().get(Options.SEARCH_HIGHLIGHT)) {
            vim.getSearchAndReplaceService().highlight(lastSearch);
          }
        }
        vim.getRegisterManager().setSearch(lastSearch);
      }
    }