提交 48cd52e4 编写于 作者: S Sandeep Somavarapu

Improve Keyboard navigation while removing entries from results

上级 e2287690
......@@ -98,24 +98,42 @@ export class RemoveAction extends Action {
}
public run(retainFocus: boolean= true): TPromise<any> {
if (this.viewer.getFocus() === this.viewer.getNavigator().last()) {
this.viewer.focusPrevious();
} else {
this.viewer.focusNext();
if (this.element === this.viewer.getFocus()) {
let nextFocusElement= this.getNextFocusElement();
if (nextFocusElement) {
this.viewer.setFocus(nextFocusElement);
} else {
this.viewer.focusPrevious();
}
}
let parent: any;
let elementToRefresh: any;
if (this.element instanceof FileMatch) {
parent= <SearchResult>this.element.parent();
let parent:SearchResult= <SearchResult>this.element.parent();
parent.remove(<FileMatch>this.element);
elementToRefresh= parent;
} else {
parent= <FileMatch>this.element.parent();
let parent: FileMatch= <FileMatch>this.element.parent();
parent.remove(<Match>this.element);
elementToRefresh= parent.count() === 0 ? parent.parent() : parent;
}
if (retainFocus) {
if (retainFocus && this.viewer.getFocus()) {
this.viewer.DOMFocus();
}
return this.viewer.refresh(parent);
return this.viewer.refresh(elementToRefresh);
}
private getNextFocusElement():FileMatchOrMatch {
let navigator= this.viewer.getNavigator();
while (navigator.current() !== this.element && !!navigator.next()) {};
if (this.element instanceof FileMatch) {
while (!!navigator.next() && !(navigator.current() instanceof FileMatch)) {};
return navigator.current();
} else {
return navigator.next();
}
}
}
......
......@@ -212,6 +212,10 @@ export class SearchAccessibilityProvider implements IAccessibilityProvider {
return nls.localize('fileMatchAriaLabel', "{0} matches in file {1} of folder {2}, Search result", element.count(), element.name(), paths.dirname(path));
}
if (element instanceof EmptyMatch) {
return nls.localize('emptyMatchAriaLabel', "No matches");
}
if (element instanceof Match) {
let input= <SearchResult>tree.getInput();
if (input.isReplaceActive()) {
......
......@@ -99,6 +99,9 @@ export class FileMatch extends EventEmitter implements lifecycle.IDisposable {
public remove(match: Match): void {
delete this._matches[match.id()];
if (this.count() === 0) {
this.add(new EmptyMatch(this));
}
}
public matches(): Match[] {
......@@ -204,13 +207,6 @@ export class LiveFileMatch extends FileMatch implements lifecycle.IDisposable {
return !this._model || (<ITextModel>this._model).isDisposed();
}
public remove(match: Match): void {
super.remove(match);
if (this.count() === 0) {
this.add(new EmptyMatch(this));
}
}
}
export class SearchResult extends EventEmitter {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册