-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support quick file-search with go to line
The quick file-search text box (normally accessed via Ctrl + P) now allows the option to append the input with ':' and a line number to go to. Signed-off-by: Alvaro Sanchez-Leon <alvaro.sanchez-leon@ericsson.com>
- Loading branch information
Showing
3 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2017 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { Position } from '@theia/editor/lib/browser'; | ||
import { integer } from '@theia/core/shared/vscode-languageserver-types'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
|
||
@injectable() | ||
export class FileQuery { | ||
private _filePattern: string = ''; | ||
private lineNumber: integer = 0; | ||
|
||
/** | ||
* Parses the query in its different components and returns the corresponding file pattern of the query | ||
* e.g. /path/to/file:10, will parse the query and return /path/to/file. | ||
* | ||
* @param fileQuery a file query in the form "filePathPattern:location number". | ||
* | ||
* @returns the filePathPattern portion of the query. | ||
*/ | ||
parseFileQuery(fileQuery: string): string { | ||
const queryParts = fileQuery.split(':', 2); | ||
this._filePattern = queryParts[0].trim(); | ||
|
||
const locationString = queryParts.length > 1 ? queryParts[1].trim() : ''; | ||
const locationNumber = Number.parseInt(locationString); | ||
this.lineNumber = locationNumber && locationNumber > 1 ? locationNumber - 1 : 0; | ||
|
||
return this.filePattern; | ||
} | ||
|
||
public get filePattern(): string { | ||
return this._filePattern; | ||
} | ||
|
||
public get position(): Position { | ||
return Position.create(this.lineNumber, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters