Skip to content

Commit 9f408ab

Browse files
committed
allow Ctrl-O + enter filename with line number (captured from log or exception trace) - to go straight to the line
1 parent 52d7d08 commit 9f408ab

File tree

4 files changed

+77
-53
lines changed

4 files changed

+77
-53
lines changed

lang/english.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
"Creating Folder" => "Creating Folder",
253253
"Sorry you can..." => "Sorry, you can only have 100 files open at a time!",
254254
"Opening File" => "Opening File",
255-
"Enter relative file..." => "Enter relative file path (prefixed with /) or remote URL",
255+
"Enter relative file..." => "Enter relative file path (prefixed with /) or remote URL\\nYou can enter \\n'/path/file:123' or \\n'/path/file(123)' or \\n'/path/file.ext line 123' \\nto go directly to particular line",
256256
"Getting" => "Getting",
257257
"Please enter the..." => "Please enter the new name for",
258258
"Renaming to" => "Renaming to",

lib/file-control.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php
22
include("headers.php");
33
include("settings.php");
44
$t = $text['file-control'];
@@ -68,7 +68,7 @@
6868
// If we're due to open a file...
6969
if ($_GET['action']=="load") {
7070
echo 'action="load";';
71-
71+
$lineNumber = max(isset($_REQUEST['lineNumber'])?intval($_REQUEST['lineNumber']):1, 1);
7272
if (file_exists($file)) {
7373
$finfo = "text";
7474
// Determine what to do based on mime type
@@ -173,6 +173,7 @@
173173
top.ICEcoder.content.contentWindow.CodeMirror.doFold(cM.getLine(i).indexOf("{")>-1?"brace":"xml",null,"+","-",true)(cM, i);
174174
}
175175
top.ICEcoder.loadingFile = false;
176+
top.ICEcoder.goToLine(<?php echo $lineNumber; ?>);
176177
<?php
177178
;};
178179
?>

lib/ice-coder.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,22 @@ var ICEcoder = {
11511151
// Open a file
11521152
openFile: function(fileLink) {
11531153
var shortURL, canOpenFile;
1154+
var line = 1;
1155+
if ("undefined" != typeof fileLink) {
1156+
var re = /^(.*)\s+line\s+(\d+)/;
1157+
var reMatch = re.exec(fileLink);
1158+
if (null !== reMatch)
1159+
{
1160+
line = reMatch[2];
1161+
fileLink = reMatch[1];
1162+
} else if (fileLink.indexOf(':') > 0){
1163+
line = fileLink.split(':')[1];
1164+
fileLink = fileLink.split(':')[0];
1165+
} else if ((fileLink.indexOf('(') > 0) && (fileLink.indexOf(')') > 0)){
1166+
line = fileLink.split('(')[1].split(')')[0];
1167+
fileLink = fileLink.split('(')[0];
1168+
}
1169+
}
11541170

11551171
if (fileLink) {
11561172
top.ICEcoder.thisFileFolderLink=fileLink;
@@ -1176,7 +1192,7 @@ var ICEcoder = {
11761192

11771193
if (shortURL!="/[NEW]") {
11781194
top.ICEcoder.thisFileFolderLink = top.ICEcoder.thisFileFolderLink.replace(/\//g,"|");
1179-
top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink+"&csrf="+top.ICEcoder.csrf);
1195+
top.ICEcoder.serverQueue("add","lib/file-control.php?action=load&file="+top.ICEcoder.thisFileFolderLink+"&csrf="+top.ICEcoder.csrf+"&lineNumber="+line);
11801196
top.ICEcoder.serverMessage('<b>'+top.t['Opening File']+'</b><br>'+top.ICEcoder.shortURL);
11811197
} else {
11821198
top.ICEcoder.createNewTab('new');
@@ -3133,7 +3149,13 @@ var ICEcoder = {
31333149

31343150
// CTRL/Cmd+G (Go to line)
31353151
} else if(key==71 && (evt.ctrlKey||top.ICEcoder.cmdKey)) {
3136-
top.get('goToLineNo').focus();
3152+
var goToLineInput = top.get('goToLineNo');
3153+
goToLineInput.select();
3154+
// this is trick for Chrome - after you have used Ctrl-F once, when
3155+
// you try using Ctrl-F another time, somewhy Chrome still thinks,
3156+
// that find has focus and refuses to give it focus second time.
3157+
top.get('find').focus();
3158+
goToLineInput.focus();
31373159
return false;
31383160

31393161
// CTRL/Cmd+I (Get info)

0 commit comments

Comments
 (0)