Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
2c0e7eb0
Commit
2c0e7eb0
authored
7 years ago
by
fitermay
Committed by
Elizaveta Shashkova
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
PY-26413: More intuitive caret positioning on prev
parent
c25531e7
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/lang-impl/src/com/intellij/execution/console/PrefixHistoryModel.kt
+17
-14
.../src/com/intellij/execution/console/PrefixHistoryModel.kt
platform/lang-impl/testSources/com/intellij/execution/console/ConsoleHistoryConstrollerTest.java
+14
-1
...llij/execution/console/ConsoleHistoryConstrollerTest.java
with
31 additions
and
15 deletions
+31
-15
platform/lang-impl/src/com/intellij/execution/console/PrefixHistoryModel.kt
+
17
-
14
View file @
2c0e7eb0
...
...
@@ -30,11 +30,11 @@ import gnu.trove.TIntStack
*/
private
val
MasterModels
=
ConcurrentFactoryMap
.
createMap
<
String
,
MasterModel
>(
{
MasterModel
()
},
{
ContainerUtil
.
createConcurrentWeakValueMap
()
})
{
MasterModel
()
},
{
ContainerUtil
.
createConcurrentWeakValueMap
()
})
private
fun
assertDispatchThread
()
=
ApplicationManager
.
getApplication
().
assertIsDispatchThread
()
...
...
@@ -53,7 +53,7 @@ fun createModel(persistenceId: String, console: LanguageConsoleView): ConsoleHis
private
class
PrefixHistoryModel
constructor
(
private
val
masterModel
:
MasterModel
,
private
val
getPrefixFn
:
()
->
String
)
:
ConsoleHistoryBaseModel
by
masterModel
,
ConsoleHistoryModel
{
ConsoleHistoryModel
{
var
userContent
:
String
=
""
override
fun
setContent
(
userContent
:
String
)
{
...
...
@@ -119,23 +119,26 @@ private class PrefixHistoryModel constructor(private val masterModel: MasterMode
override
fun
getHistoryPrev
():
Entry
?
{
val
entries
=
myEntries
?:
return
null
val
currentPrefix
=
getPrefixFn
()
if
(
myPrevEntries
.
size
()
>
0
)
{
myCurrentIndex
=
myPrevEntries
.
pop
()
return
entries
[
myCurrentIndex
]
.
let
{
Entry
(
it
,
-
1
)
}
return
createPrevEntry
(
entries
[
myCurrentIndex
]
,
currentPrefix
)
}
else
{
resetIndex
()
return
Entry
(
userContent
,
-
1
)
return
createPrev
Entry
(
userContent
,
currentPrefix
)
}
}
private
fun
createPrevEntry
(
prevEntry
:
String
,
currentPrefix
:
String
):
Entry
=
if
(
prevEntry
.
startsWith
(
currentPrefix
))
Entry
(
prevEntry
,
currentPrefix
.
length
)
else
Entry
(
prevEntry
,
0
)
override
fun
getCurrentIndex
():
Int
=
if
(
myCurrentIndex
!=
-
1
)
{
myCurrentIndex
}
else
{
entries
.
size
-
1
}
if
(
myCurrentIndex
!=
-
1
)
{
myCurrentIndex
}
else
{
entries
.
size
-
1
}
override
fun
prevOnLastLine
():
Boolean
=
true
...
...
This diff is collapsed.
Click to expand it.
platform/lang-impl/testSources/com/intellij/execution/console/ConsoleHistoryConstrollerTest.java
+
14
-
1
View file @
2c0e7eb0
...
...
@@ -96,8 +96,21 @@ public class ConsoleHistoryConstrollerTest extends LightPlatformCodeInsightTestC
execStatementList1
();
setCaretWithText
(
"Statement<caret> 4"
);
consoleNext
();
consoleNext
();
consolePrev
();
checkResultByText
(
"Statement<caret> 4"
);
}
//PY-26413
public
void
testNavigateDown2
()
{
execStatementList1
();
setCaretWithText
(
"<caret>Statement 4"
);
consoleNext
();
consoleNext
();
setCaretWithText
(
"Statement<caret> 3"
);
consolePrev
();
checkResultByText
(
"
Statement 4<caret>
"
);
checkResultByText
(
"
<caret>Different Prefix
"
);
}
public
void
testNavigateUpNoPrefix
()
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help