Skip to content

Commit

Permalink
Fix search for wide unicode
Browse files Browse the repository at this point in the history
Part of xtermjs#1103
  • Loading branch information
Tyriar committed Jan 16, 2018
1 parent be18507 commit 8d3bdad
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/addons/search/SearchHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,17 @@ export class SearchHelper {
private _findInLine(term: string, y: number): ISearchResult {
const lowerStringLine = this._terminal.buffer.translateBufferLineToString(y, true).toLowerCase();
const lowerTerm = term.toLowerCase();
const searchIndex = lowerStringLine.indexOf(lowerTerm);
let searchIndex = lowerStringLine.indexOf(lowerTerm);
if (searchIndex >= 0) {
const line = this._terminal.buffer.lines.get(y);
for (let i = 0; i < searchIndex; i++) {
// Adjust the selection for empty characters following wide unicode chars
const char = line[i];
const charWidth = char[2/*CHAR_DATA_WIDTH_INDEX*/];
if (charWidth === 0) {
searchIndex++;
}
}
return {
term,
col: searchIndex,
Expand Down

0 comments on commit 8d3bdad

Please sign in to comment.