Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search addon is off on lines containing emojis #1103

Closed
Tyriar opened this issue Nov 2, 2017 · 2 comments
Closed

Search addon is off on lines containing emojis #1103

Tyriar opened this issue Nov 2, 2017 · 2 comments
Labels
help wanted type/bug Something is misbehaving
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Nov 2, 2017

VS Code issue: microsoft/vscode#37440

image

@Tyriar Tyriar added addon type/bug Something is misbehaving help wanted labels Nov 2, 2017
@Tyriar Tyriar changed the title Find addon is off on lines containing emojis Search addon is off on lines containing emojis Nov 2, 2017
@marg51
Copy link

marg51 commented Jan 16, 2018

The error most likely comes from https://github.com/xtermjs/xterm.js/blob/master/src/addons/search/SearchHelper.ts#L117

I suppose a quick fix could look like:

private _findInLine(term: string, line: number): ISearchResult {
  const lowerStringLine = this._terminal.buffer.translateBufferLineToString(line, true).toLowerCase()
  const lowerTerm = term.toLowerCase()
  const searchIndex = lowerStringLine.indexOf(lowerTerm)

  if (searchIndex >= 0) {
    // ⬇️

    for (let i = 0; i < searchIndex; i++) {
      const current_char_width = this._terminal.buffer.lines[line][i][CHAR_DATA_WIDTH_INDEX]

      if (this._terminal.buffer.lines[line][CHAR_DATA_WIDTH_INDEX] === 0) 
          searchIndex--
      else if (this._terminal.buffer.lines[line][CHAR_DATA_WIDTH_INDEX] === 2) 
          searchIndex-- 
    }

    // ⬆️
    return {
      term,
      col: searchIndex,
      row: line,
    }
  }
}

I wish I could do more, but this addon has no tests.

Tyriar added a commit to Tyriar/xterm.js that referenced this issue Jan 16, 2018
Tyriar added a commit to Tyriar/xterm.js that referenced this issue Jan 16, 2018
@Tyriar
Copy link
Member Author

Tyriar commented Jan 16, 2018

Thanks @marg51, you were on the right track. I put a PR out to fix this #1211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type/bug Something is misbehaving
Projects
None yet
Development

No branches or pull requests

2 participants